I'm struggling with some "foreach" loops that I have created in the following script.
The basic idea of the script is the following:
1.) Create folder and folder names from a directory of $sourcefiles, and move the folders to the $userdir.
2.)Then, copy a common set of files to each folder.
3.) Assign a CRON job to each folder based on the programming below. The CRON jobs begin at 0 0 * * * and execute at 5 minute intervals, essentially running every five minutes.
4.) NOW I'M STUCK: I've got the output to produce the correct CRON command by folder, but the foreach CRON time loop does not execute correctly! It starts on 55 23 * * * instead of 0 0 * * *, then 5 0 * * *, then 10 0 * * * etc. for each folder...
See sample output below the code:
Here's the output:
use File::Copy::Recursive qw(dircopy);
$userdir = "/var/www/web12/web/";
$sourcefiles = "/home/source";
$sourcedir = "play";
$ftd1 = "bm";
opendir $sourcedir, ".";
@contents = grep /$ftd1/, readdir $sourcedir;
foreach $listitem ( @contents )
mkdir ($listitem, 0777);
foreach ($count=0; $count<=287; $count++)
$aminutes = ($count * 5);
$hrs = int($aminutes / (60));
$min = int($aminutes - ($hrs*60));
print OUT_FILE "$min $hrs * * * /usr/bin/php /var/www/web12/web/".$listitem."/myfolder/rollcall.php \n";
55 23 * * * /usr/bin/php /var/www/web12/web/bmaaa/myfolder/rollcall.php
55 23 * * * /usr/bin/php /var/www/web12/web/bmaab/myfolder/rollcall.php
Thanks for any help!