Avatar of StevenHook
 asked on

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

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.
LinuxLinux DistributionsLinux Networking

Avatar of undefined
Last Comment

8/22/2022 - Mon
Steven Vona

Try something like this in a bash script:

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

Open in new window


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 Vona

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks so much for the help.
They still running :( I think I might run out of disk space soon :(
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy