4 # Fetches all crontabs on the hosts specified on the command line
5 # and presents them sorted on user, machine and time.
7 # @author Petter Reinholdtsen <pere@td.org.uit.no>
8 # @params host1 [host2 ...]
10 # @version $Id: cron-summary,v 1.1 2003/06/02 13:01:37 pere Exp $
13 $crondir = "/var/spool/cron/crontabs";
14 $rsh = $ENV{RSH} || 'rsh';
18 foreach $host (@hosts) {
19 @users = &get_cronusers($host);
20 print "Users at $host: ".join(",", @users)."\n";
21 foreach $user (@users) {
22 &parse_crontab($host, $user);
29 # Fetches the contents of $crondir from $host and returns all users as
36 local($res) = `$rsh $host echo $crondir/\\*`;
37 $res =~ s%$crondir/%%g;
38 local(@users) = split(/\s+/, $res);
43 # Fetches the crontab-file for $user from $host and stores the info in
45 # @params $host, $user
46 # @return "" on failures and "1" on success.
48 local($host, $user) = @_;
49 open(CRONTAB, "rsh $host cat $crondir/$user|") ||
50 die "Unable to open crontab on $host for $user";
53 ($min, $hour, $dom, $moy, $daw, $command) =
54 m/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/;
55 push(@cron,join(":", $user, $host, $hour, $min, $dom, $moy, $daw, $command));
62 # Prints the crontab summary based on the info in @cron
63 sub show_cronsummary {
64 local($lastuser, $lasthost);
65 foreach $line (sort @cron) {
68 ($user, $host, $hour, $min, $dom, $moy, $daw, @command) =
70 if ($user ne $lastuser) {
71 print "\nUser: $user\n";
74 print " Host: $host\n" if ($host ne $lasthost);