Output a list of cron settings for all users.

1 minute read


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


Each part of the command 2 has the following processing contents.


``` cut -f1 -d

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.



This article is a migration article from the blog “Technical Notes for Chores Engineers”. The previous blog will be deleted.