[LINUX] One liner that beautifully displays cron for all users

Thank you for always being indebted to https://qiita.com/ironsand/items/fb05869080f6ed724816.

When there were many users, it was difficult to see because there were many users who were no crontab, so I made it easier to see.

for user in $(cut -f1 -d: /etc/passwd); do echo -n :kaigyo1:[${user}]:kaigyo2:;\
 crontab -u $user -l 2>&1 ; done  | grep -v "no crontab" | sed s/:kaigyo1:/\\n\\n/ \
 | sed s/:kaigyo2:/\\n/

1 line version

for user in $(cut -f1 -d: /etc/passwd); do echo -n :kaigyo1:[${user}]:kaigyo2:; crontab -u $user -l 2>&1 ; done  | grep -v "no crontab" | sed s/:kaigyo1:/\\n\\n/  | sed s/:kaigyo2:/\\n/

Only for root users.

Output image

[root@myserver ~]# for user in $(cut -f1 -d: /etc/passwd); do echo -n :kaigyo1:[${user}]:kaigyo2:; crontab -u $user -l 2>&1 ; done  | grep -v "no crontab" | sed s/:kaigyo1:/\\n\\n/ | sed s/:kaigyo2:/\\n/


[a_san]
#Ansible: kirei ni suru
0 6 * * * /bin/bash /home/a_san/hamigaki.sh >> /tmp/hamigaki.log
#Ansible: energy hokyu
10 6 * * * /bin/bash /home/a_san/asa_gohan.sh >> /tmp/asa_gohan.log


[c_san]
#Ansible: miharasi ii
1 10 * * 0 /usr/bin/yamanobori --config /etc/yamanobori.yml /etc/yamanobori_action_file.yml

(b_san is a no crontab image)

Recommended Posts

One liner that beautifully displays cron for all users
One liner that randomly rewrites the startup time of cron
One liner that lists the colors of matplotlib
The one that displays the progress bar in Python