Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab help 2

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hi. I want to run Webalizer daily at 12:05 am. Here is my crontab, but it's not running. I have to run it manually. My lines don't wrap and my paths are correct. Anacron seems to be running.

Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

# sysstat
0 * * * 0,6 /usr/lib/sa/sa1 600 6 &
5 19 * * * /usr/lib/sa/sa2 -A &

# webalizer (run every day at 12:05 am)
5 0 * * * /usr/src/webalizer/webalizer -c /etc/webalizer_vhost1.conf &
5 0 * * * /usr/src/webalizer/webalizer -c /etc/webalizer_vhost2.conf &
 
Hi,



That looks OK to me ... Are you sure that crond is running and running as root ?



ps -aux | grep crond



/sbin/chkconfig --list crond



If it is, what does it say in the log files, i.e /var/log/cron, /var/log/cron.1, etc ?



Regards







 
Are the permissions correct on the binary ? Ian

"IF" is not a word it's a way of life
 
Here is what I get from those commands:

Code:
root  730  0.0  1.1  1520  748  ?   S  Nov18 0:00 crond
root 3787  0.0  0.7  1330  452 tty1 R  11:17 0:00 grep crond

and:

Code:
crond  0:off  1:off  2:on  3:on  4:on  5:on  6:off

Sometimes it's frustrating to be a newbie. :(

Thanks.
 
Oh, and there doesn't seem to be anything related to this in my logs.
 
String could be too long.
Write a wrapper, place your commands in it and exec the wrapper instead after verifying that the script works as you want it to.

--------------------------------------------------------------
#!/bin/sh
/usr/src/webalizer/webalizer -c /etc/webalizer_vhost1.conf
/usr/src/webalizer/webalizer -c /etc/webalizer_vhost2.conf
#end
--------------------------------------------------------------

chmod 700 scriptname mv scriptname /root/bin && crontab -e

This way you can also do some logging and error checking for each process as it runs if you want.
ex:
cmd1="/usr/src/webalizer -c /etc/webalizer_vhost1.conf"

eval $cmd1 || echo -e "Failed_$0_$?,$_, `date`" | logger

 
Thanks for your help. I tried the above suggestion and here is what I got:

Code:
Webalizer V2.01-09 (Linux 2.2.16-22) English
Using logfile /etc/httpd/logs/vhost1-access_log (clf)
Creating output in /home/vhost1/stats
Hostname for reports is '[URL unfurl="true"]www.vhost1.com'[/URL]
Reading history file... webalizer_vhost1.hist
Generating report for November 2001
Generating summary report
Saving history information...
14 records in 0.49 seconds

But it still isn't running automatically!
 
Frozenpeas,
Sorry, I'm always forgetting that linux isn't
everybody's native language.

assumptions:
You have created the wrapper.
You have placed it in /root/bin(or wherever)
and made it executable ; chmod 700 wrapper.

The last thing to do is modify your crontab
: try this:
5 23 * * * /root/bin/wrapper

This should work.

Also you could enter the cmd substitution(prev post) in
your crontab and run the one liner instead.
 
Ahhh!!!! Marsd! I didn't have the permissions set right! I am betting this will run tomorrow morning... I can't believe I overlooked that.

Linux is definitely NOT my native language, but I am glad you are fluent.

Thank you very much!

frozenpeas
 
Argh!!! No go. It STILL isn't running.

There is nothing in the cron logs, either.

Any ideas???
 

You said the script ran by itself right?
There is another reason then why it should not run
from the crontab. Maybe you should do a couple of tests:

This is a root crontab right?
run the script at certain intervals:
25 12,17,19 * * * /root/bin/wrapper | logger
try it with exec /root/bin/wrapper | logger

Have you checked all logs for the times
you mentioned? The webalizer logs as well?
As a side note, are the other cron jobs running?
I do not believe that 0 is a valid time for
cron,it may be, but a positive value leaves no
room for doubt.

 
It is a root crontab. I can't find anything in the logs. The script does work properly.

As far as 0 being a valid time for cron, it is (from what I have found). It can be 0-23.

I will try to run it with logger and see what happens.

Thanks.
 
Hi,







What marsd has already advised seems perfectly logical to me - can't see why it doesn't work if the script itself works...







Anyway, if you install webalizer from redhat rpm the following script is placed in /etc/cron.daily :











#! /bin/bash



# update access statistics for the web site







if [ -s /var/log/httpd/access_log ] ; then



/usr/bin/webalizer



fi







exit 0







(owner/group root and permissions 755).







It is actually named 00webalizer so that it is executed before all the other scripts in /etc/cron.daily .







What I would try is to create a directory called (for example) /etc/cron.daily2 and place your equivalent webalizer script in it. Then edit /etc/crontab so that you have 'run-parts' (/usr/bin/run-parts script) do what it does for /etc/cron.daily but at a different time :







# run-parts



01 * * * * root run-parts /etc/cron.hourly



02 4 * * * root run-parts /etc/cron.daily



22 4 * * 0 root run-parts /etc/cron.weekly



42 4 1 * * root run-parts /etc/cron.monthly



5 0 * * * root run-parts /etc/cron.daily2







That is essentially the same as marsd' suggestion but is called the way that redhat calls other cron controlled scripts so maybe it might work....







Regards











 
Put a line in the beginning of your webalizer to make a flag file. If you see this flag file, then the webalizer is wrong and your cron is correct.

soumething like "touch /export/home/webcronflag"
 
Great, it's finally working!

My crontab now looks like this:

Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

# sysstat
0 * * * 0,6 /usr/lib/sa/sa1 600 6 &
5 19 * * * /usr/lib/sa/sa2 -A &

# webalizer (run daily at 12:05 am)
05 0 * * * root run-parts /etc/cron.daily2

Thank you, everyone for your help.

frozenpeas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top