3

I want see all the jobs that has been scheduled by using cron for the last 1 week (or certain specified time). I used the command

sudo grep CRON /var/log/syslog

But it only shows the log for 1 day. Is there any command in Ubuntu to track them?

3

You can do this to newer syslog files:

cd /var/log
cat syslog.1 syslog | grep CRON

To the oldest you must do it:

cd /var/log
zcat syslog syslog.4.gz syslog.3.gz syslog.2.gz | grep CRON

It's a good idea to do these commands nested in loops, specially to zcat, since syslog.#.gz are more numerous.

You can even store them into another file to analyze better:

cd /var/log
zcat syslog syslog.4.gz syslog.3.gz syslog.2.gz | grep CRON > ~/cronanalysis.txt
cat syslog.1 syslog | grep CRON >> ~/cronanalysis.txt

The order of syslog files is inverted, so you put older to head and newer events to tail.

4

Another alternative is

sudo zgrep CRON /var/log/syslog*

zgrep uncompresses files if needed. Options same as for grep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.