When you want to Sleep

man-489744_640_optSometimes I want to end the day… but then I hear the hard drive of my trusty machine working away. And what is it doing? Maybe backups, maybe a cron job.

But either way, I don’t want to turn it off…

So instead I run a little command. It just waits while the good little problematic program is running and when it exits, it starts a 60 second countdown until the machine powers off:

while [ -n "$(pgrep -fl run-parts)" ] ; do sleep 10 ; done ; echo "Shutdown in 60 seconds" ; shutdown -h +1

(Substituting ‘run-parts’ for whatever command you are waiting to end.)

And then I can sleep.