On Thursday 27 April 2006 08:06 pm, Chris Climbed A Telegraph Pole and
Clicked:
> I've got a very simple perl script that I'm trying to run as a cronjob.
>
> #!/usr/bin/perl
>
> use LWP::Simple qw(mirror $ua);
>
> $| = 1;
>
> $ua->timeout(60);
> my $url = 'http://www.sanesecurity.com/clamav/phish.ndb.gz';
> my $file = 'phish.ndb.gz';
> my $dbfile = 'phish.ndb';
>
> my $result = mirror($url, $file);
> print "$file\t$result\n";
> if ($result == 200) {
> system "gunzip -v --stdout $file > $dbfile";
> }
> exit 0;
>
> Its use is to check for new updates to the phish.ndb file used by clamav.
> It runs fine from the cli so I know there is no issue with the script,
> however, when attempting to run as a cronjob I get:
>
> phish.ndb.gz 500
>
> which I'm told by the author is a
>
> A 500 status code is an internal server error. Nothing to do with the
> script.
>
> He also goes on to say:
>
> "99% of all problems under Unix are permissions"
>
> Aside from it being under cron, what else is different. UserID,
> evnironment, shell, PWD, etc ?
>
> All my other cronjobs run correctly. Below is my crontab and permission
> settings for /usr/local/bin/Phish.pl
>
> SHELL=/bin/bash
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
> [EMAIL PROTECTED]
> HOME=/
> # run-parts
> 1 * * * * root nice -n 19 run-parts /etc/cron.hourly
> 2 * * * * clamav /usr/local/bin/freshclamcron
> 0 * * * * root /usr/local/etc/logcheck.sh
> 33 21 * * * chris /usr/local/bin/Phish.pl
>
> #
> 2 4 * * * root nice -n 19 run-parts /etc/cron.daily
> #
> 22 4 * * 7 root nice -n 19 run-parts /etc/cron.weekly
> #
> 42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly
>
> Permissions are set as below:
>
> [EMAIL PROTECTED] bin]# ls -lr Phish.pl
> -rwxrwxr-x 1 root root 331 Apr 26 18:56 Phish.pl*
>
> Whether running this job as root or chris nets the same output. Any
> suggestions or help would be much appreciated.
You might try running the cron job with screen. You'll have to read up on
screen to see how you want it to work with your particular program.
I haven't run your script but it looks like you'll want the -m flag and if you
direct your print commands to a > newfile, the -d flag might be what you'll
want as well. so screen -d -m /path/to/script
Hope this helps
benja22
--
"You have been in Afghanistan, I perceive."
-- Sir Arthur Conan Doyle, "A Study in Scarlet"
____________________________________________________
Want to buy your Pack or Services from Mandriva?
Go to http://store.mandriva.com
Join the Club : http://www.mandrivaclub.com
____________________________________________________