I have a script that I want to try and run daily for archive purposes. I
have no clue on constructing a proper "crontab" to do this. Any
information will be greatly appreciated. Thank you.

Dennis

                 #!/usr/bin/perl



      # Use crontab to run this every night at 11:58pm or so
                 @M =
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
                 "Oct","Nov","Dec")
                 @tm = localtime(time); # Use to grab current date
                 $thedate = sprintf("%4d%3s%2d",
                 (1900 + $tm[5]) , $M[$tm[4]], $tm[3]);
                 $thedate =~ s/ /0/g; # Turn 1-9 to 01-09
                 open(NEWARCH,">./messages/$thedate.txt");
                 open(CHAT,"<Chat1.html");
                 print NEWARCH <<ArchHeader;
                 <HTML>
                 <HEAD><TITLE>Archive for $thedate</TITLE>
                 </HEAD>
                 <BODY>
                 <H4>Add whatever content you need as a header in the
                 archive file</H4>
                 ArchHeader
                 while(<CHAT>)
                 {
                 # Print all lines to new file once we find --add here--

                 if (/--add here--/) { $printing_on = 1; }
                 if ($printing_on) { print NEWARCH; }
                 }
                 close(NEWARCH);
                 close(CHAT);

                 # Save copy of archive.html
                 rename "archive.html", "archive-old.html";
                 open(OLDA,"<archive-old.html");
                 open(NEWA,">archive.html");
                 while(<OLDA>)
                 {
                 # Print new archive file after the <tt> line
                 if (/<tt>/)
                 {
                 print <<Newline;
                 <a href="messages/$thedate.html">$thedate.html</a>
                 Newline
                 }
                 print NEWA;
                 }
                 close(OLDA);
                 close(NEWA);

                 rename "Chat1.html","Chat1-old.html";
                 open(OLDC,"<Chat1-old.html");
                 open(NEWC,">Chat1.html");
                 while(<OLDC> && $leave_loop == 0)
                 {
                 print NEWC;
                 # Leave loop after we find -add here- line
                 if (/--add here--/) { $leave_loop = 1; }
                 }
                 close(OLDC);
                 close(NEWC);

Reply via email to