Cron
By Will Bontrager2004-01-09
A Practice Script
You can use the following script to practice what you have learned.
#!/usr/bin/perl
# Verify above line is correct for your server.
use strict;
my @date = localtime;
$date[4]++;
$date[5] += 1900;
$date[5] = substr($date[5],2);
open W,">track.txt";
print W "$date[2]\:$date[1]\:$date[0] on ";
print W "$date[4]\/$date[3]\/$date[5]\n";
# Above is USA style date. For European
# style, reverse digits 4 and 3.
close W;
# end of practice script
The script will create a file named "track.txt" and print the time and date. Every time it runs, it creates a new file. The script is specifically made for running from the telnet/SSH prompt or with cron, not for a browser. (Running this script in your browser will generate an internal server error. That's because the script never returns anything to the browser.)
When the script is uploaded, you can test it from the telnet/SSH prompt. To test, type the command you'll be using when you create the cron schedule.
Once the script runs correctly, create the cron schedule. You may wish to use */3 or something similar in the minute field while testing. As you now know, that will launch the script every three minutes; then the longest you'll wait between tests is three minutes.
Once the test is over, remove the test script from the cron schedule. Launching a script, whether with cron or through a browser, does take some server resources.
Tutorial Pages:
» Cron
» The Cron Table
» The Five Schedule Time Fields
» Hypothetical Situations
» The Hypothetical Situations Schedules
» The Sixth Field, The Command
» On-line Documentation for cron and crontab
» A Practice Script
» Conclusion
Copyright 2004 Bontrager Connection, LLC
| Related Tutorials: » How to Install PHP 5 on Linux » How to Install Apache 2 on Linux » How to Install MySQL 5.0 on Linux » SMB Caching » Mound --Bind » Tar Wild Card Interpretation |
