On 2005-08-02 21:15:11 +0200, The List Man
<li********@esotericwonders.com> said:
Crontabs for automatic site updates.
Does anyone know how to set up a crontab for automatically updating
a webpage on a regular basis. We know how to set these to run perl
files, but seem to have an issue as far as comming up with the command
to copy one html file to replace another. Any help or simple scripts
to do this will be greatly appreaciated.
Shell commands between ``s will be executed. So you can do:
`cp $source $destination`
If you want to keep the output (so you can check if something went wrong):
$output = `cp $source $destination`
For example, if you want to copy index.html to index.7.17.2005.html,
and then copy a new file to index.html (with the dates changing
everyday):
#!/usr/bin/env perl
# get the date
($s, $m, $h, $d, $M, $y, $wd, $doy, $dst) = localtime(time);
$y += 1900;
$d--;
$yesterday = "$M.$d.$y"; // yesterday's date m.d.y
# paths
$path_to_website = "/var/www/html";
$path_to_new_file = "/home/myself/website/index.html";
# copying
`cp ${path_to_website}/index.html ${path_to_website}/index.$yesterday.html`;
`cp ${path_to_new_file} ${path_to_website}/index.html`;