How To verify Whether Cron Job is Working or Not.

By | September 24, 2019

Everybody know the importance of cron Job and uses it multiple times in Various scenarios.  Creating a Cron Job is easy to create but, Several user Still get confused whether their Cron Job is Working Regularly or on the defined date time or not. User are not even very sure about how to identify whether the cron job is running or not.
Here, I will show a simple command or a way to identify this.  It Can be identified Using a Simple Linux Command. 
ideally It can be identified by checking the Cron logs which resides in /var/log/, but the log size could be very huge and could be hard to find out the.
So Let’s get started. Just create a Simple shell script and set the the cron Job for it.

# vim test.sh
#!/bin/bash
echo "Current System time is:`date +%H:%M:%S` >> /root/output.txt

It Is Just a sample shell script Which Will capture the current time of the Server and will redirect it to output.txt file.
Now, provide execute permission to the file

# chmod +x test.sh

Set the Cron Job to Run Every minute using the below pattern

# crontab -e
 * * * * /root/test.sh 

Now to Identify whether the cron Job is running or not,  Just Use the below command. It Just a Simple command but useful.

For Ubuntu Systems
root@devospage:~# grep "test.sh" /var/log/syslog

For CentOS
root@devospage:~# grep "test.sh" /var/log/cron

So here we can see that the Job is running Successfully for every minute.


 

If you Like Our Content here at Devopsage, then please support us by sharing this post.

Please Like and follow us at, LinkedInFacebookTwitter, and GitHub

Also, Please comment on the post with your views and let us know if any changes need to be done.
Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *