Skip to content

Instantly share code, notes, and snippets.

@mnebuerquo
Last active April 12, 2018 13:56
Show Gist options
  • Save mnebuerquo/b5c1b79c275442c0ce5d0eb17bb8ab4e to your computer and use it in GitHub Desktop.
Save mnebuerquo/b5c1b79c275442c0ce5d0eb17bb8ab4e to your computer and use it in GitHub Desktop.
list all cron jobs of all users on system
#!/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