Solved

crontab not working as expected on SuSE linux

Posted on 2004-09-24
7
765 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

734 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