Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Displaying cron jobs for all users.

  • 20-09-2007 09:15AM
    #1
    Registered Users, Registered Users 2 Posts: 8,780 ✭✭✭


    Hi,
    There was a post on this forum which seems to have disappeared :( . It showed how to get a crontab listing for all users by parsing the passwd file and then display the crons for each user found.

    Can anybody remember how this was done?


Comments

  • Registered Users, Registered Users 2 Posts: 231 ✭✭anonymousjunkie


    This is probably it, if you're talking linux anyway

    cut -d: -f1 /etc/passwd | grep -vE "#" | xargs -i{} crontab -u {} -l


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    you could look in /var/spool/cron/crontabs


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    I was gonna suggest:

    crontab -l | tee `awk -F":" '{ print $1}' /etc/passwd

    I tested this on Solaris 10 and it works. It wont work on SuSE 9.2 as it seems tee is only passing back the first user, which is root.


  • Registered Users, Registered Users 2 Posts: 8,780 ✭✭✭degsie


    Thanks guys, I have something to go on from here. I need this for Solaris 8 & 9 and for Tru64 systems. Thanks again.


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    the command i posted should work for you so, the only problem is there is no way of identifying which crontab belongs to which user then they are all together


  • Advertisement
  • Closed Accounts Posts: 7,562 ✭✭✭leeroybrown


    One point to note is that /etc/passwd isn't necessarily an authoritative list of all user accounts on a system. It is only one potential source albeit the most common. It's a far better idea to use 'getent passwd' in any scripts that do this as it will include all potential NSS passwd sources (LDAP, NIS, PAM-MySQL, ...) and as such avoid problems should extra sources be added.


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    thats a nice command, thanks


Advertisement