Listing All Crontabs For All Users

Today I found myself needing to find if any crontabs were set up on a server. But how do I find out if there are any under all the usernames?

Simple.

First become the root user:

sudo -s

Then do the following command:

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

I don’t fully understand it in terms of syntax, but it basically goes through all of the users on the servers (which are in /etc/passwd) and displays their name followed by any crontabs that are under than name.

This answer was found on Stack-Overflow here, so be sure to rate it if you found it useful.


© 2012-2017