I had the need recently to find a cron job on a server. I was logged in as root, but I didn’t know who the cron job was set up as.
You can get a list of all users who have cron scheduled tasks by running the following command:
1 |
[root@server ~]# ls -l /var/spool/cron |
This allows you to see the users, although if you’ve got a general idea, then looking in /etc/passwd would give you an idea too.
So, the cronjob might be running as any of these users. Usually to get your crontab you can just run:
1 |
[root@server ~]# crontab -l |
Or to edit it:
1 |
[root@server ~]# crontab -e |
As root, you get the chance to tell crontab which user you’d like to view. Like this:
1 |
[root@server ~]#crontab -u username -l |
Image Credit: jlcwalker
Comment or tweet @douglasradburn