LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-13-2010, 08:14 PM   #1
jonnybignote
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Rep: Reputation: 0
cron problems


Hi all

running 9.10 x64

My scripts in cron.daily are not running correctly.

I am not using Anacron but waking my computer every night to run cron jobs - does that mean I should remove the anacron references from the cron lines or can they be left as is?

This is my current file (note, I've commented out the originals)

Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

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

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
#09 04  * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
09 04   * * *   root    cd / && run-parts --report /etc/cron.daily
#04 04  * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
04 04   * * 7   root    cd / && run-parts --report /etc/cron.weekly
#06 04  1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
06 04   1 * *   root    cd / && run-parts --report /etc/cron.monthly
my cron logging is messed up and all I get is one line saying its started (cron.daily etc) without any individual script details. So figuring out what is going wrong is difficult

if I type into terminal


Code:
run-parts --report /etc/cron.daily
the scripts will run but they have all kinds of permissions errors relating to creating files or directories so I have problems there also....

I'm starting to lose track of this system as it seems to have inherited various oddities and corruptions over the last 2 years, due in great part I imagine to my haphazard knowledge of linux.

This machine running my mythtv so it would be nice if I didn't have to reformat and start again but many of the scripts running are important and I need to figure this out.

Any help will be much much appreciated

Thanks
 
Old 08-13-2010, 09:24 PM   #2
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
This is actually a very simple and common mistake. Cron is designed to run scripts, not commands. If the script needs advanced arguments then those should be placed in a master script to be called from cron. So save the following as a script and call that one script with cron.

Code:
###########################################################
#/bin/bash
test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
###########################################################
 
Old 08-13-2010, 11:18 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,788
Blog Entries: 17

Rep: Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316Reputation: 3316
Quote:
Originally Posted by joec@home View Post
Cron is designed to run scripts, not commands.
You just put into words something that I had sensed.

Though I do also have cron also running programs, in particular, podracer. The developer told me how to do it at his website.
 
Old 08-14-2010, 01:05 PM   #4
jonnybignote
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Original Poster
Rep: Reputation: 0
well I can do that for sure if you think it will help, but its probably worth mentioning that the line you noted is part of the default crontab installed with the system - shouldn't it work as is - out of the box?

I had commented those lines out anyway and was just trying to get it to work without the anacron part

ex.
cd / && run-parts --report /etc/cron.daily
 
Old 08-22-2010, 04:39 PM   #5
jonnybignote
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Original Poster
Rep: Reputation: 0
so, to recap.

Cron is running...sort of. It doesn't seem to run with the right privileges as evidenced in some of the items in cron.daily folder getting permission denied messages in their logs.

Also, my cron.log only lists 1 line per each script loaded, rather than a more detailed account.

I've obviously messed up something over the last 2 yrs or so. Any help much appreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cron.hourly cron.weekly cron.monthly and 0anacron. Are they necessary? glore2002 Debian 2 09-30-2009 09:57 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 02:50 PM
CRON problems jlinden Linux - General 1 09-02-2003 03:16 PM

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

All times are GMT -5. The time now is 06:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration