script runs fine, just not as a cron job

Permabanned
Joined
17 Oct 2002
Posts
172
Location
/dev/null
i'm written a very simple bash script to run webalizer on my web logs, and it works fine. when i set up a cron job to run it every half hour however, it says the command cannot be found :confused:

just running it:
Code:
[root@Gemini root]# sh /home/stat-www.pl
Webalizer V2.01-10 (Linux 2.4.18-3smp) English
Using logfile /home/www/logs/access.log (clf)
Creating output in current directory
Hostname for reports is 'Gemini.ihateaol.co.uk'
Reading history file... webalizer.hist
Generating report for October 2002
Generating report for November 2002
Generating summary report
Saving history information...
11704 records in 0.71 seconds
[root@Gemini root]#

but i get this email when it is run as a cron job:
Code:
From
[email][email protected][/email] (Cron Daemon)
To
[email][email protected][/email]
Date
Thu, 14 Nov 2002 20:00:01 GMT
Subject
Cron <root@Gemini> sh /home/stat-www.pl

/home/stat-www.pl: webalizer: command not found

any ideas?
 
Permabanned
OP
Joined
17 Oct 2002
Posts
172
Location
/dev/null
all it is is:

#!/bin/bash

cd /home/www/html/misc/stat
webalizer /home/www/logs/access.log

has to change to the stat directory first cos thats where it generates the files when webalizer is run
 

Ben

Ben

Associate
Joined
18 Oct 2002
Posts
2,328
Location
Kent
Probably the script doesn't run with the path to where webalizer is.

try using the full path to it.

need help finding it?
do
Code:
whereis webalizer
from a shell :)
 
Permabanned
OP
Joined
17 Oct 2002
Posts
172
Location
/dev/null
i perfer find / -name webalizer ;)

also, running the cron job manually worked, and nothing had any trouble finding webalizer any other time. we'll see if this works in 25 mins anyway
 
Man of Honour
Joined
18 Oct 2002
Posts
7,097
Yeah, you'll need to put in the full path of webalizer. With everything in cron you will need full paths. So something like:
Code:
#!/bin/bash

cd /home/www/html/misc/stat
/usr/bin/webalizer /home/www/logs/access.log
 

Ben

Ben

Associate
Joined
18 Oct 2002
Posts
2,328
Location
Kent
Originally posted by Lucifer
woohoo!
*kisses ben

now how do i stop it mailing me every half hour telling me it worked?


*steps away slowly* heh

From the top of my crontab file (crontab -e)

# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null. We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)

for example
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null

HTH :)


EDIT: beaten to it by Mpemba Effect *sigh*
 

fIREfox

F

fIREfox

How did you install it into cron? Pop the script into /etc/cron.hourly or into crontab -e?

Im guessing its the first in which case it probs a cron config setting.... a quick look round /etc and I cant see anything obvious tho..
 
Permabanned
OP
Joined
17 Oct 2002
Posts
172
Location
/dev/null
sweet :D

now for the super simple problem... the server clock is wrong, how can i set it and keep it synchronised?

i added "server <time server IP>" to /etc/ntp.conf but i dunno what to do from there. RH 7.3
 
Permabanned
OP
Joined
17 Oct 2002
Posts
172
Location
/dev/null
Originally posted by fIREfox
How did you install it into cron? Pop the script into /etc/cron.hourly or into crontab -e?

Im guessing its the first in which case it probs a cron config setting.... a quick look round /etc and I cant see anything obvious tho..

crontab -e, cos i want it every 30 mins. fix0red now anyway thx :)
 

Ben

Ben

Associate
Joined
18 Oct 2002
Posts
2,328
Location
Kent
Originally posted by Lucifer
sweet :D

now for the super simple problem... the server clock is wrong, how can i set it and keep it synchronised?

i added "server <time server IP>" to /etc/ntp.conf but i dunno what to do from there. RH 7.3

If I were you i'd just add a cronjob that just runs
/usr/sbin/ntpdate <server>

e.g.
/usr/sbin/ntpdate ntp.pipex.net

:)
 
Permabanned
OP
Joined
17 Oct 2002
Posts
172
Location
/dev/null
[root@Gemini etc]# /usr/sbin/ntpdate ntp.demon.nl
15 Nov 00:01:46 ntpdate[15656]: step time server 194.159.73.44 offset 3400.608745 sec

haha :D you guys rock
thanks a lot
 
Back
Top Bottom