#!/usr/bin/perl use strict; use warnings; use CGI qw/:cgi-lib :standard/; use CGI::Carp qw(fatalsToBrowser); print header; #Instructions ################## #Set this to the server path to the crons.txt my $pathtocrontxt="./cron.txt"; # In the crons.txt put the first line as 0 and then put each cronjob on a seperate line below # set the chmod permissions to crons.txt to 777 and cron.cgi to 755 my @commands; my $lines = 0; ##################################### print "Running Crons...\n"; if( open my $inf,"<",$pathtocrontxt ){ @commands = <$inf>; close $inf; chomp @commands; for my $line(@commands){ if( $lines == 0 && $commands[$lines] == 0 ){ print "not working\n"; $commands[0] = 1; write_file(); } elsif($lines == 0 && $commands[$lines] == 1){ print "working\n"; $commands[0] = 0; write_file(); exit; } else { print "Executing: $line\n"; my $output = system("$line"); print "$output\n"; } $lines++; } $commands[0] = 0; } print "\n\nDone!\n"; sub write_file{ if( open my $out, '>', $pathtocrontxt ){ print $out $_,"\n" for @commands; } }