Solved

crontab not working as expected on SuSE linux

Posted on 2004-09-24
7
745 Views
Last Modified: 2008-01-09
I have always set a cronjob as follows(say on RedHat):

crontab -e

and then type in the command in there like:

0,30 * * * *       root    /path/to/cron_script >/dev/null

I am doing exactly the same in SuSE linux....but it simply won't work!!

I then tried to write the same command in a file under /etc/cron.d/ (yast2-online-update is also under this directory). It still doesn't work!!!

What am I doing wrong???!!
0
Comment
Question by:sandeep_th
  • 5
  • 2
7 Comments
 
LVL 6

Expert Comment

by:blkline
ID: 12144835
You should be using:

0,30 * * * *  /path/to/cron_script > /dev/null

The extra "root" in there is probably screwing things up.  If this crontab entry is for "root" then it will be run as "root".

Barry
0
 
LVL 6

Expert Comment

by:blkline
ID: 12144917
Looking at my comment I should have been clearer.

If you want to run this as "root", then put it root's crontab.  You can get the specifics of the crontab format by typing:

man 5 crontab

Barry
0
 

Author Comment

by:sandeep_th
ID: 12145011
Doesn't work....it says in the SuSE Linux admin manual that(quoted verbatim):

/etc/crontab cannot be processed with crontab -e . It must be loaded directly into an editor, modified, then saved.

On opening /etc/crontab I found the following lines:

SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
59 *  * * *     root  rm -f /var/spool/cron/lastrun/cron.hourly
14 4  * * *     root  rm -f /var/spool/cron/lastrun/cron.daily
29 4  * * 6     root  rm -f /var/spool/cron/lastrun/cron.weekly
44 4  1 * *     root  rm -f /var/spool/cron/lastrun/cron.monthly

So I added one of my own at the end:

* * * * *       root  rm -f /path/to/doodle

which should simply remove the file /path/to/doodle ...every minute.

It simply doesn't do it!!
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Accepted Solution

by:
blkline earned 125 total points
ID: 12145192
Ahhh... there is the system crontab (which is in /etc), and there is a per-user crontab.  I hadn't thought about the one in /etc because I never modify that.  Sorry about that...

Did you restart the cron daemon after you changed the file?

/etc/init.d/cron restart

Barry
0
 
LVL 6

Expert Comment

by:blkline
ID: 12145276
I know that you aren't supposed to have to restart cron when you make a change to this but I was more interested so as to ensure that you have cron started!

Assuming that cron is running,  /pat/to/doodle is not marked immutable, is it?   Just for fun you can do something like this:

* * * * * root echo date >> /tmp/testdrive

and you should see a line added once per minute to the file.

Barry
0
 

Author Comment

by:sandeep_th
ID: 12154290
That was it....i had to restart the cron daemon with :
/etc/init.d/cron restart

and it worked!!

editing crontab -e wouldn't require u to restart it...I wonder why they changed it!!

Also....just for interest....how do u mean "marked immutable"?
0
 
LVL 6

Expert Comment

by:blkline
ID: 12155479
The file can't be changed by anyone.  It's a safeguard against accidental (or malicious) change.

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now