1

I have a rogue cron job that runs every 10 minutes on a Centos system.

How do I find all the jobs that are performed?

  • How do you know it's a cron job? – coredump Aug 17 '10 at 14:56
1

See this question on StackOverflow (How do I list all cron jobs for all users?). The short version is that you could run the following (@Kyle Burton's answer on that question):

for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done

There is also a more indepth script that you could copy and run on that post.

  • thats pretty cool . – jini Aug 17 '10 at 17:11
  • 1
    jini: Be aware that this is not necessarily going to find your rogue job. It will only work if your rogue job is in a crontab of a current user and not in /etc/crontab or /etc/cron.daily/* etc or a crontab of a deleted user. – Richard Holloway Aug 17 '10 at 17:20
2

Or if you're root, just check the directory /var/spool/cron/tabs. In there should be a complete list of all user crons. There are also crons that run out of the /etc/cron* directories. Just run:

# ls -l /etc/cron*
# ls -l /var/spool/cron/tabs/

To see them all.

2

You could do something like this:

for crontab in `ls /etc/cron.*/* /var/spool/cron/* /etc/crontab`
do
    echo $crontab
    cat $crontab
done

And remember to check the log file /var/log/cron or similar which will list everything that has been run by cron.

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.