Thursday, October 6, 2022

[SOLVED] How to view a cron job running currently?

Issue

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?


Solution

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



Answered By - Cwissy
Answer Checked By - Pedro (WPSolving Volunteer)