How to list cronjob entries of all users?

How to list all cron entries on a WHM/cPanel based servers?

Crontab is the program used to install, remove or list the tables used to drive the cron daemon. Cronjobs are predefined jobs which are running periodically according to the settings we have done previously. In the /etc folder there is a file called crontab where we can write the command or name of the script that is to be executed at as per our customized time. You can refer the link pasted below to schedule jobs using crontab.

CryBit here going to explain how we can list all cron entries created by cPanel users in a WHM based server. This can be done by different ways from Linux CLI (command line interface) as you imagine. Here is the small piece of code that helps to list all cron jobs:

The basic command to list the cron entries for a single user is “crontab -u user -l” Here we can use for loop to list all users’ cron jobs. See the snippet pasted below:

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

Cool. If you want a detailed check, all cron jobs are defined in the following location. You can check the details from over there.

# cd /var/spool/cron


# cd /var/spool/cron
[email protected] [/var/spool/cron]# ll
-rw------- 1 root root 18 Dec 31 16:04 ailt
-rw------- 1 root root 40 Nov 8 2015 helffko
-rw------- 1 root root 1.7K May 9 13:44 mailman
-rw------- 1 root root 1 May 20 08:08 mone
-rw------- 1 root root 6 May 19 06:02 root
-rw------- 1 root root 40 Aug 25 2015 run22

You can see files with user names. Just view that file for cron jobs for that user, that’s it!!

Also you can use this simple script to list all cronjobs for users:

1. Create a file “
2. Add the following code into that file:

cd /var/spool/cron
ls -1 > /root/cronusers.txt
for i in `cat /root/cronusers.txt`
  echo "######For the user $i######" >> /root/cronlist.txt
  echo "" >> /root/cronlist.txt
  cat $i >> /root/cronlist.txt
  echo "" >> /root/cronlist.txt
  echo "###########################" >> /root/cronlist.txt
  echo "" >> /root/cronlist.txt

3. Save and quit
4. Execute “

# sh

5. Now you can see the result from “/root/cronlist.txt

That’s it!!


Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

Leave a Reply

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