LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-19-2015, 07:07 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Rep: Reputation: 35
Question Script in /etc/cron.daily not running


Hello

This is the first time I'm using a script through Cron so that it runs daily. FWIW, the host is runnin Debian 7.

I simply put a script in /etc/cron.daily yesterday, but it doesn't seem to run.

Is there an additional step? How do I investigate why it's not running?

Thank you.
 
Old 06-19-2015, 09:37 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,476

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Check that the script has the correct execution permissions.
Check that any non-shell commands that the script runs are being accessed using /the/full/path/to/the/command
If you're using bash then use set -x as the second line of the script and that will give you some logging.
 
Old 06-19-2015, 07:24 PM   #3
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Thanks for the help.

I put "set -x" on the second line, right after "#!/bin/bash", and will check /var/log/messages tomorrow.

The script relies on wget, grep, and sed.

Do I need to specify where those live in the system?

Thank you.
 
Old 06-20-2015, 12:02 PM   #4
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Nothing interesting in /var/log/messages:
Code:
rsyslogd: [origin software="rsyslogd" swVersion="5.8.                                      11" x-pid="1553" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
I assume this is due to adding "set -x" in my Bash script. But otherwise, still no cigar.

Next, I followed this post, and added the following to my script:
Code:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
As a test, I moved my script from /etc/cron.daily to /etc/cron.hourly, and checked after a couple of hours: Still no output, and nothing in /var/log/messages.

Mmm
 
Old 06-20-2015, 05:40 PM   #5
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Looks like simply putting a script in /etc/cron.hourly isn't enough:

Code:
/etc/cron.hourly# ll
-rwxr-xr-x  1 root root  152 Jun 20 23:26 test.bash*

/etc/cron.hourly# cat test.bash
#!/bin/bash

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

echo "This line from test.bash" > /tmp/from.test.script

/etc/cron.hourly# cat /etc/crontab
# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
I waited until the next :17, but nothing turned in /tmp.
 
Old 06-20-2015, 06:24 PM   #6
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Next, I ran "/etc/init.d/cron restart", and waited until :17. Still no trace of the output in /tmp.

FWIW,
Code:
/etc/cron.hourly# ps aux | grep cron
root      4152  0.0  0.1   3800   780 ?        Ss   00:47   0:00 /usr/sbin/cron
root      4189  0.0  0.1   3552   816 pts/0    S+   01:23   0:00 grep cron
I didn't expect this to be so involved.
 
Old 06-21-2015, 06:40 AM   #7
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Problem solved.

Look in the Debian sub-forum for more infos.

http://www.linuxquestions.org/questions/debian-26/
 
  


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
Scripts in cron.daily are not running daily abefroman Linux - Server 1 12-23-2014 12:11 PM
/etc/cron.daily/webalizer not running? sneakyimp Linux - Server 26 09-03-2011 04:26 PM
cron - how to give priority to a task running in cron.daily? MeeLee Linux - Newbie 3 11-09-2010 08:41 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Problem With Script in cron.daily fizbang Linux - Newbie 10 03-21-2005 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:58 AM.

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