Как узнать, как долго выполняется команда для использования команды времени?

448
JoeNyland

Я долго mysqldumpработал уже более 2 дней (многие сотни гигабайт данных заархивированы). Я начал команду с timeтого, чтобы я мог видеть, сколько времени прошло, когда она закончилась.

Есть ли сигнал, который я могу отправить, чтобы timeон распечатал количество времени, прошедшее с момента запуска команды?

0

2 ответа на вопрос

2
Stefan Seidel

I would assume that you started it with time mysqldump ..., which most likely uses the shell built-in time, not /usr/bin/time or /bin/time. I don't think there's a possibility to make it print the time.

However, you can cd /proc/$(pgrep mysqldump) and check some statistics there. If all you want to know is how long it is since you started it, you can just run

ps faxo pid,cls,stat,pri,euser,pcpu,etime,rss:8,args 

which will show the elapsed time in the 7th column as "days-hours:minutes:seconds".

0
cricket_007

If you run ps aux | grep mysqld the tenth column should show you the running time of the process.

The second column shows the process id (say XYZ), and you can check that in realtime by running top -pid XYZ.

Похожие вопросы