nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

list every user's crontab script

This is a discussion on list every user's crontab script within the Shell scripting forums, part of the Development/Scripting category; Hi everyone, I have a small issue. I have a lot of users on my server and I would like ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-22-2005, 06:05 PM
Junior Member
User
 
Join Date: Feb 2005
Posts: 23
Rep Power: 0
marinm
Default list every user's crontab script

Hi everyone,

I have a small issue. I have a lot of users on my server and I would like to check out their crontab, but doing it manually would take a lifetime.
Can anyone help me with a small script which will read /etc/passwd and output every user's crontab? The command is crontab -u user -l I think.
Any ideas?

Thank you.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-23-2005, 11:52 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

That is quite easy
Code:
cat /etc/passwd | cut -d: -f1 | xargs crontab -l -u
Test it and lemme know...
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 03-23-2005, 02:35 PM
Junior Member
User
 
Join Date: Feb 2005
Posts: 23
Rep Power: 0
marinm
Default

Hi,

I get an error when trying to execute the command:

root@orbit [~]# cat /etc/passwd | cut -d: -f1 | xargs crontab -l -u
crontab: usage error: no arguments permitted after this option



Kind Regards
Reply With Quote
  #4 (permalink)  
Old 03-23-2005, 08:09 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default



Sorry try as follows

Code:
a=$(cat /etc/passwd | cut -d: -f1)
for i in $a
do
 crontab -u $i -l
done
This one should work, let me know...
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #5 (permalink)  
Old 07-19-2005, 08:20 AM
Junior Member
 
Join Date: Jul 2005
Posts: 1
Rep Power: 0
brew
Default

Quote:
Originally Posted by nixcraft
That is quite easy
Code:
cat /etc/passwd | cut -d: -f1 | xargs crontab -l -u
Test it and lemme know...
i try above in freebsd..this is what i got:

-bash-2.05b# cat /etc/passwd | cut -d: -fl | xargs crontab -l -u
cut: [-cf] list: illegal list value
-bash-2.05b#
Reply With Quote
  #6 (permalink)  
Old 07-20-2005, 12:24 AM
Guest
 
Posts: n/a
Default

Following is correct command for FreeBSD:
Code:
cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -I {} crontab -u {} -l
And for linux it should be as follows:
Code:
cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -l
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
crontab click007 Getting started tutorials 6 10-19-2007 05:45 PM
Alphabetical file name and list logged in user script oronno Shell scripting 5 08-22-2007 01:10 PM
Crontab lacloai Linux software 2 06-01-2007 04:44 AM
start and stop service in crontab. gthian Shell scripting 7 05-31-2007 12:04 PM
about crontab darknet Shell scripting 2 01-04-2007 07:01 PM


All times are GMT +5.5. The time now is 06:06 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36