0

Say I have this process with PID = 1234 currently running.

I don't know how long it's gonna take for it to finish. Is it possible to schedule a cron tab to keep checking for the status of the proccess and shutdown the machines as soon as it sees that the process has finished?

I'm a fairly amateur shell-scripter, so I'm not sure where to start ....

1 Answer 1

0

If you're just looking at the PID, a crontab is probably the wrong place to do this. You might just want to write a script that checks periodically and then shuts the machine down instead. On Linux, you could do:

while [ -d /proc/1234 ] ; do
sleep 30; # or however long you want the interval to be
done
/sbin/shutdown -h now

That will need to be run as root to shut down without a password. Other ways of finding the PID can be found here: https://serverfault.com/questions/366474/whats-a-proper-way-of-checking-if-a-pid-is-running

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .