PERL: Help w/ "foreach" loops and building a Crontab entry - Just need some advice
Hi All,
I'm struggling with some "foreach" loops that I have created in the following script.:scratch: 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: Code:
#!/usr/bin/perl Code:
55 23 * * * /usr/bin/php /var/www/web12/web/bmaaa/myfolder/rollcall.php |
I'm a little confused by the description, but couldn't you just use something like this in your cron to run it every 5 min?
*/5 * * * * /usr/bin/php /var/www/web12/web/bmaaa/myfolder/rollcall.php */5 * * * * /usr/bin/php /var/www/web12/web/bmaab/myfolder/rollcall.php Regarding the script it looks like you should replace foreach ($count=0; $count<=287; $count++) with for ($count=0; $count<=287; $count++) |
I gave it a second look and if I understand what you want to do correctly, you would also need to move your print OUT_FILE line to the inside of the for($count=0; $count<=287; $count++) block
|
yeah, you are doing the entire loop, then using the final results. BTW, for & foreach are the same word in Perl. (TMTOWTDI)
Which you use tends to depend on your prev lang(s). |
> for & foreach are the same word in Perl
I can't believe I've been wasting 4 keystrokes all this time. |
Thanks for your help, I was able to get a functioning product
Hi All,
:newbie: Thanks for your help, I was able to get a functioning product! :D |
All times are GMT -5. The time now is 02:47 AM. |