One Liner: Check Cron Jobs for All Users on a *nix Server

If you are ever in a situation where you are asked to find out whether or not a server is being used for anything important, some of the first things you would want to check is whether or not there are active websites, databases and automated tasks. Automated tasks often times are run by the Cron daemon on behalf of a user on the server. If you would like to check the Crontab entries for all users on the server, you can run a one-line command as a super user and get a nice long list of who does and does not have a Crontab entry:

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

The “grep -v” after the pipe simply ensures that no lines starting with a hash mark (#) are listed.



Comments are closed.

Post Navigation