2016-09-18 48 views
0

我需要能夠使用bash創建腳本來報告特定組的成員(用戶在此組中),將輸出寫入文件並使用crontab安排腳本Bash腳本報告組的成員

我也做了crontab的一部分,但不知道這也是正確的:

- 5:55am: 55 5 * * 1-5 /bin/sh /home/test/membersofgroup.sh 
- 9:55am: 55 9 * * 1-5 /bin/sh /home/test/membersofgroup.sh 
- 3:55pm: 55 15 * * 1-5 /bin/sh /home/test/membersofgroup.sh 

問候。

+0

我想' - 5:55 am:'實際上不是在crontab,你剛纔用的是,這裏的說明。如果這是正確的,那麼你有什麼看起來是正確的。但是SO不適合用'crontab'尋求幫助,unix.stackexchange.com是一個更好的地方。 – Barmar

+0

您可以將它們組合成一行:'55 5,9,15 * * 1-5/bin/sh/home/tycho/membersofgroup.sh' – Barmar

+0

您可以列出用戶:'awk -F \:'/^ specific:/ {print $ 4}'/ etc/group> file.txt'。輸出將如下所示:'user1,user2,user3 ...'。 –

回答

0

結合@ Barmar的crontab進入我的awk

$ cat >> crontab_file_of_yours.txt 
55 5,9,15 * * 1-5 awk -F\: '/^specific:/ && $0=$4' /etc/group >> /pathto/file.txt 
$ crontab crontab_file_of_yours.txt