I have a cron job set up for daily execution (on my own ubuntu, just for trial) like so:
0 0 * * * /path/exec.sh
It is been set for daily execution. I usually open my machine around 8a.m. I would like to find out
- what time my cron job ran, if it has already run ?
- I would also like to see if any of my cron job is running at the moment?
Is there a way to find out IF a cron job is actually running at the moment?
So a simple ls -lrt /path/cron. {start,end} will tell you when the job started and if it is still running (the order will tell you if it is still running). Or even better, have your cron job write a log file with timestamps so you can see how it's progressing.
View Current Logged-In User's Crontab entries : To view your crontab entries type crontab -l from your unix account. View Root Crontab entries : Login as root user (su – root) and do crontab -l. To view crontab entries of other Linux users : Login to root and use -u {username} -l.
to check if cron is actually running anything at this moment in time (works on ubuntu)
pstree -apl `pidof cron`
and you'll either get
2775,cron # your pid (2775) will be different to mine :-)
or a tree output with all the child processes that cron is running (it may not name them if you don't have sufficient privileges) and as Hamoriz says the logs are in /var/log/syslog so
grep CRON /var/log/syslog
will get you the logs just for cron
I would also like to see if any of my cron job is running at the moment?
ps aux |grep "path/exec.sh"
what time my cron job ran ?
Cron log only show when start task off crond, not log when end. You need put this on your task or embedded your task en one scritp with control time of start and end.
if it has already run ?
cat /path/logs/messages or /path/logs/file when your system put logs of crond (this depends on your distribution settings or your computer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With