I have this Perl script for monitoring a folder in Linux.
To continuously check for any updates to the directory, I have a while loop that sleeps for 5 minutes in-between successive loops :
while(1) {
...
sleep 300;
}
Nobody on my other question suggested using cron
for scheduling instead of a for loop.
This while
construct, without any break looks ugly to me as compared to submitting a cronjob using crontab :
0 */5 * * * ./myscript > /dev/null 2>&1
- Is cron the right choice? Are there any advantages of using the while loop construct?
- Are there any better ways of doing this except the loop and cron?
Also, I'm using a 2.6.9 kernel build.