简体   繁体   English

Linux:停止tar命令吗?

[英]Linux: Stopping tar command?

Uh I badly messed up today, I was going to backup my whole website folder (public_html) and didn't realize that it was 24GB, now it's eating up disk usage and I have no idea how to stop it. 呃,我今天很糟,我打算备份我的整个网站文件夹(public_html),却没有意识到它是24GB,现在它正在消耗磁盘空间,我不知道如何停止它。 The command I used was: 我使用的命令是:

tar -cvpzf  /home/mywebsite/public_html/backup.tar.gz /home/mywebsite/public_html/

I deleted the existing backup.tar.gz from the directory but the command is still running and is still eating up disk space (even though the .tar.gz file no longer exists). 我从目录中删除了现有的backup.tar.gz,但该命令仍在运行,并且仍在占用磁盘空间(即使.tar.gz文件不再存在)。 How do I stop this? 如何停止呢?

ps -ef | grep tar

Figure out the tar command's PID, then kill it with. 找出tar命令的PID,然后将其杀死。

kill <pid>

For instance, kill 1234 if it is PID 1234. Wait a bit, and if it hasn't died gracefully from that then hit it with the sledgehammer. 例如,如果它是PID 1234,则kill 1234 1234。请稍等一下,如果它没有因此而优雅地死掉,请用大锤将其击中。

kill -9 <pid>

Alternatively, you could kill all running tar commands with a single command. 或者,您可以使用单个命令杀死所有正在运行的tar命令。

pkill tar

# if necessary
pkill -9 tar

Either way, once the process dies, the disk space will clear up. 无论哪种方式,一旦进程终止,磁盘空间将被清除。 Deleting the file didn't help because a running process still has the file open. 删除文件没有帮助,因为正在运行的进程仍打开了该文件。 Files aren't truly deleted until they're removed and they're not open in any process. 在删除文件并且在任何过程中都无法打开文件之前,不会真正删除文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM