Cron is a daemon process for the task scheduler that runs on Unix-like servers. Since the cron settings (task schedule) can be set for each user, it takes a lot of time to issue the bash command to check all the settings in the server.
# 1.Move to administrator privileges
su -
# 2.Output cron settings for each user
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
# 3.Get out of administrator privileges
exit
Each part of the command 2 has the following processing contents.
/etc/passwd
The content is divided by the delimiter ":" on each line of the password file "/ etc / passwd", and the value of the first item (user name) is extracted.
``` $(○○○) ```
Execute and expand the command.
``` for ××× in △△△; do □□□; done ```
Each item of △△△ is stored in XXX and the processing of □□□ is executed.
``` echo $××× ```
Output the contents of XXX. (The user name is output in this command)
``` crontab -u $××× -l ```
Output cron settings for xxx users.
# reference
* [Display a list of cron jobs for all users --Qiita](https://qiita.com/ironsand/items/fb05869080f6ed724816)
* [unix - How do I list all cron jobs for all users? - Stack Overflow](https://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users)
# Remarks
This article is a migration article from the blog "[Technical Notes for Chores Engineers](https://scrapbox.io/nezuq/)". The previous blog will be deleted.
Recommended Posts