Crond in 3 lines of perl

From meaning
Jump to: navigation, search

Here's the core of crond in 230 characters (3 lines) of perl:

by Glenn Powers

@t=localtime(time);$t[5]++;while($_=<STDIN>){($_=~s/^[\d\,\*]*($t[1]|\*)[\d\,\*]
* [\d\,\*]*($t[2]|\*)[\d\,\*]* [\d\,\*]*($t[3]|\*)[\d\,\*]* [\d\,\*]*($t[4]|\*)[
\d\,\*]* [\d\,\*]*($t[6]|\*)[\d\,\*]* ([^\#]*).*$/\6/)&&system($_);};

use:

foreach $user (</var/spool/cron/*>){ system("su $user --command="perlcron <$user" | mail $user")};


Site Information
Personal tools