Link to home
Start Free TrialLog in
Avatar of StevenHook
StevenHook

asked on

Can I set a cron to mail me when a process ends?

Hi,
I have an rsync that's been running for a few days now (since thursday)
But it should end tonight I think (estimate based on disk usage)
Can I get help making a script that I can put in cron that will mail me a simple "done" when the rsync process ends?
There are actually 2 different rsync's sunning, so I think it'll have to work on the PID to know which one is done.
Cron already mails me the outputs of commands, but the rsyncs weren't  run by cron, I started them in a console.
Tx.
Steve
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Try something like this in a bash script:


if ps ax | grep -v grep | grep <PID OF RSYNC>  > /dev/null
then
            echo "The process exists and is still runing" >> $RUNLOG 2>&1
else
            mail -s "RSYNC DONE" email@yourdomain.com
fi

Open in new window

Avatar of StevenHook
StevenHook

ASKER

It was complaining about $RUNLOG 2>&1
so I sent it to /dev/null instead
now the email is waiting for the rest of the message, if that makes sense?
Steven
ASKER CERTIFIED SOLUTION
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:D
Thanks so much for the help.
They still running :( I think I might run out of disk space soon :(