As root, how can I list the crontabs for all users?
Well depends on the script but easily you can find your crontab as root with
crontab -l -u <user>
Or you can find crontab from spool where is located file for all users
cat /var/spool/cron/crontabs/<user>
To show all users' crontabs with the username printed at the beginning of each line:
cd /var/spool/cron/crontabs/ && grep . *
One liner which lists all users and prints cron for every user:
for user in $(getent passwd | cut -f1 -d: ); do echo $user; crontab -u $user -l; done
This solution:
- Doesn't require knowing a system specific crontab path (e.g.
/var/spool/cron/crontabs/
vs/var/spool/cron/
- Won't list "orphan" crons, i.e. crons for users that don't exist anymore (and thus are not executed effectively)