On 2005-08-02 21:15:11 +0200, The List Man
<li********@eso tericwonders.co m> 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_websit e = "/var/www/html";
$path_to_new_fi le = "/home/myself/website/index.html";
# copying
`cp ${path_to_websi te}/index.html ${path_to_websi te}/index.$yesterda y.html`;
`cp ${path_to_new_f ile} ${path_to_websi te}/index.html`;