One of my WordPress installs has been migrated recently and I'm trying to delete the directory of the old one but it's taken over 15 minutes to delete. It looks like it's deleting each individual file. Is this normal? Can it just do a folder delete and run itself in the background? For comparison, on Mac (Unix) it takes half a second.
3 Answers
Can it just do a folder delete and run itself in the background? For comparison, on Mac (Unix) it takes half a second.
This is not just an SFTP issue but also a non-local (aka: networked) file system issue. When you are on your Mac—or any OS; just directly on the system—you have direct access to your file system. And since the filesystem is—really simplifying it but for clarity—just a small database/index with file/directory location pointers. So what happens when you delete a file or directory locally is that local file system database/index file is acted on fairly quickly since it is—of course—local.
In contrast, when accessing a file system remotely via a networking protocol such as SFTP, you don’t have direct access to the file system. So if you have to delete every file/directory via a network connection, first the network connection needs to get a list of files/directories from the remote file system. And the when the program gets that list, then it will run the remote action to remove a file. This method is quiet inefficient and which is why having some form of direct file system access is always preferred.
That said, if you have an SFTP account you should also have SSH access since an SFTP connection is typically just managed as an SSH subsystem. So if you are going nuts waiting for files/directories delete just login via SSH and run an rm -rf
command on the files/directories in question.
Usually if you have sftp access you'll also have ssh access and you can execute remote commands using that. So to recursively remove a directory structure you would use the -r parameter to the rm command. i.e.
ssh [email protected] "rm -rf /home/user/directory"
Be very careful with this command and be 100% of the directory you're deleting is the correct one. You can also list the contents of the directory to be sure by doing this.
ssh [email protected] "ls /home/user/directory"
The secure file transfer protocol doesn't provide for direct access to the operating system's API.
This pretty much means no.
Deleting via SSH might be faster, if you have shell access.
Can it just do a folder delete and run itself in the background?
- No.