Help us understand the problem. What is going on with this article?

全ユーザのcronを綺麗に表示するワンライナー

いつも https://qiita.com/ironsand/items/fb05869080f6ed724816 にお世話になってました(ありがとうございます)

ユーザが多いと no crontab なユーザが多くて見難かったので、見やすく表示できるようにしました。

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行版

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/

root ユーザ限定です。

出力イメージ

[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は no crontab なイメージ)

ystmg
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした