LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron problems (https://www.linuxquestions.org/questions/linux-newbie-8/cron-problems-826112/)

jonnybignote 08-13-2010 08:14 PM

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

joec@home 08-13-2010 09:24 PM

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 )
###########################################################


frankbell 08-13-2010 11:18 PM

Quote:

Originally Posted by joec@home (Post 4065725)
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.

jonnybignote 08-14-2010 01:05 PM

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

jonnybignote 08-22-2010 04:39 PM

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.


All times are GMT -5. The time now is 10:43 AM.