LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron is not working (https://www.linuxquestions.org/questions/linux-newbie-8/cron-is-not-working-759176/)

narendrakumar 10-02-2009 06:17 AM

Cron is not working
 
Hi please have a look in the following scenario:

I gave an entry in /etc/crontab as follows:
35 11 * * * root find /tmp/* -mtime +1 -exec rm -f {} \; > /etc/test/cronlog.log

after this, from someone suggestions i restarted crond available under /etc/init.d/crond restart

even after this no result...then i checked /var/log/cron log file...there i could see the following:

Oct 2 11:35:01 vsl001a004 crond[3223]: (*system*) BAD FILE MODE (/etc/crontab)


no result from the above stuff..can someone tell me what could be the reason and solution for this.

Thanks

bathory 10-02-2009 06:34 AM

Hi and welcome to LQ

You can put your command in a script and use crontab to run the script instead.
Mind that is always better to use absolute pathnames for commands and scripts in crontab, like "/usr/bin/find ...", /path/to/my/script.sh"

Regards

rn_ 10-02-2009 06:53 AM

Are you editing the /etc/crontab file directly? what are the permissions set on that file? They should be set to 644. if not, i'd advise you change it.

Also, just in case you were editing the file directly, if you need to make an entry for cron, you should use the 'crontab -e' command.

HTH.
-RN.

donanap 10-02-2009 07:13 AM

How are you editing your crontab?
 
Hi,

Instead of going in and editing the /etc/crontab file directly, have you tried editing your crontab by doing the following?
Code:

crontab -e
This will open up the crontab file in vi. As you save it, it will confirm if the syntax is correct, if so, it will save it and add an entry, if not it will reject your effort.

Good Luck,
Donanap

Ralfredo 10-02-2009 07:48 AM

The error message is:

Quote:

Originally Posted by narendrakumar (Post 3704879)
Oct 2 11:35:01 vsl001a004 crond[3223]: (*system*) BAD FILE MODE (/etc/crontab)

So i guess there's something wrong with permissions and/or ownership of the file. On my machine (Debian/Lenny) the right permission are:

Code:

-rw-r--r-- 1 root root 718 2008-11-23 07:40 /etc/crontab
My guess is that crond (wisely) refuses to trust the file if anyone else than root has the ability to alter the contents of the file.

narendrakumar 10-02-2009 08:14 AM

After changing permissions it works fine
 
Thanks a lot..After changing permissions it works fine...

Narendra

narendrakumar 10-02-2009 10:51 AM

Can someone suggest best practices on unix administration and please provide some links if you find.#

Thanks
Narendra

narendrakumar 10-02-2009 10:52 AM

unix administration - best practices
 
Can someone suggest best practices on unix administration and please provide some links if you find.

Thanks
Narendra

lutusp 10-02-2009 07:23 PM

Quote:

Originally Posted by narendrakumar (Post 3705136)
Can someone suggest best practices on unix administration and please provide some links if you find.

Thanks
Narendra

1. Open a Web browser.

2. Type "google.com" in the address bar.

3. Type your inquiry.

4. Press the Enter key on your keyboard.

Imagine the time saved compared to asking us, and us asking Google.


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