Last active
April 12, 2018 13:56
-
-
Save mnebuerquo/b5c1b79c275442c0ce5d0eb17bb8ab4e to your computer and use it in GitHub Desktop.
list all cron jobs of all users on system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# first, find out if we're sudo | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so."; | |
exit 1; | |
fi | |
for user in $(cut -f1 -d: /etc/passwd); do | |
crons=$(crontab -u $user -l 2>/dev/null | grep -v '^#') | |
if [ 0 = $? ]; then | |
echo "$user" | |
echo "$crons" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment