LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2009, 05:05 PM   #1
hopefull
LQ Newbie
 
Registered: Jan 2009
Distribution: Debian Etch/Lenny, RedHat Enterprise 5.2.
Posts: 20

Rep: Reputation: 0
script not executed by cron.daily


I have a strange problem with cron.daily

My script is very simple:
cat my_script

#!/bin/sh

/usr/bin/touch /home/user_test/touch_cron

From shell this script is correctly executed; also
run-parts /etc/cron.daily

executes correctly the script

But if i put it in cron.daily, it is not executed

I have already checked cron is running and permissions on files and directory are ok

I do not understand, can sameone hep me?
Thanks
 
Old 01-15-2009, 05:21 PM   #2
gaurav.s.agrawal
LQ Newbie
 
Registered: Nov 2008
Posts: 5

Rep: Reputation: 0
Could you try redirecting both the output and error to a log file. I am not sure it will work, but it will be worth trying.

Hope this helps !!!
 
Old 01-15-2009, 05:41 PM   #3
hopefull
LQ Newbie
 
Registered: Jan 2009
Distribution: Debian Etch/Lenny, RedHat Enterprise 5.2.
Posts: 20

Original Poster
Rep: Reputation: 0
/usr/bin/touch /home/user_test/touch_cron > /home/user_test/error 2>&1

but i have same prblem, script is not executed in cron.daily
 
Old 01-15-2009, 05:47 PM   #4
yzhong
Member
 
Registered: Jun 2007
Location: sydney
Distribution: redhat , ubuntu, centos
Posts: 56

Rep: Reputation: 16
Did you check the error log, like /var/log/cron?
 
Old 01-15-2009, 06:12 PM   #5
hopefull
LQ Newbie
 
Registered: Jan 2009
Distribution: Debian Etch/Lenny, RedHat Enterprise 5.2.
Posts: 20

Original Poster
Rep: Reputation: 0
yes
the only message is as:

Jan 16 01:32:01 localhost /usr/sbin/cron[3755]: (*system*) RELOAD (/etc/crontab)
Jan 16 01:33:01 localhost /USR/SBIN/CRON[8427]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))


I have seen if i pt file i cron.hourly it works well!

my crontab is:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
07 * * * * root cd / && run-parts --report /etc/cron.hourly
55 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
 
Old 01-15-2009, 06:55 PM   #6
yzhong
Member
 
Registered: Jun 2007
Location: sydney
Distribution: redhat , ubuntu, centos
Posts: 56

Rep: Reputation: 16
in bash "something || other" means that if "something" is FALSE then do "other". In crontab "run-parts --report /etc/cron.daily" will only happen when
"test -x /usr/sbin/anacron" is false. /usr/sbin/anacron does exist.
Testing in the terminal
$ test -x /usr/sbin/anacron || echo "xxx"
gave no echo. changing || to && gave the echo.
Meaning that since /usr/sbin/anacron exists the cron.daily will never happen!

So deleted the "test -x /usr/sbin/anacron ||" part in crontab,like
....
55 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
to just
55 1 * * * root cd / && run-parts --report /etc/cron.daily
....

Plus the test for /usr/bin/anacron ensures that cron runs the daily, weekly and monthly script only if anacron is not installed. Take a look at the file /etc/anacrontab. It is also configured to run the daily, weekly, and monthly scripts.If your anacron works well, no need to do the above change. Also grep -i 'anacron' /var/log/syslog will show you some useful info.

Last edited by yzhong; 01-15-2009 at 07:15 PM.
 
Old 01-17-2009, 09:54 AM   #7
hopefull
LQ Newbie
 
Registered: Jan 2009
Distribution: Debian Etch/Lenny, RedHat Enterprise 5.2.
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks very much
How you see i 'm really a newbie!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/cron.daily/find script sulekha Ubuntu 1 11-09-2008 03:06 AM
Script not being run in cron.daily hazmatt20 Linux - General 10 10-12-2008 08:24 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Shell script in cron.daily ;Where does the log go ? jeepescu Linux - General 2 12-03-2007 06:07 PM
Problem With Script in cron.daily fizbang Linux - Newbie 10 03-21-2005 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration