Given I've added the clearme.sh
script in /etc/cron.hourly/
Just filter CRON tasks in terminal with the powerful egrep and awk:
$ cat /var/log/syslog | egrep clearme | awk "{ print $1 }" > ~/Desktop/cronlog.txt
The output will look like:
Jan 14 15:20:01 markets-dev CRON[10089]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 15:40:01 markets-dev CRON[18042]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 16:00:01 markets-dev CRON[22817]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 16:20:01 markets-dev CRON[28183]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 16:40:01 markets-dev CRON[411]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 17:00:01 markets-dev CRON[5442]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
Jan 14 17:20:01 markets-dev CRON[11935]: (dminca) CMD (root /etc/cron.hourly/clearme.sh)
To explain everything step-by-step:
- cat /var/log/syslog - print me the System log
- egrep clearme - but only select rows that contain the text clearme
- awk "{ print $1 }" - print me that row that contains the text clearme
- > ~/Desktop/cronlog.txt - output the results in the file cronlog.txt located on the Desktop directory.
The 4th step is optional. It will just print results in the terminal instead of the file.