Shell – status check for sleep command

findshellshell-scriptsleeptcsh

I have run sleep command in background as follow , How can I know the status of execution ..?

Command

sleep 2d ; find /home/disk1/ -exec touch {} \; &

How can I know that its executed for 1 day of sleep or is executing findcommand right now.

Best Answer

{ touch /tmp/sleep.flag; sleep 2d ; rm /tmp/sleep.flag; find /home/disk1/ -exec touch {} \; ; } &

Everything what you need just check /tmp/sleep.flag file existance

[ -f /tmp/sleep.flag ] && echo "Running sleep..."
Related Question