?
Solved

crontab not working as expected on SuSE linux

Posted on 2004-09-24
7
Medium Priority
?
770 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
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
LVL 6

Accepted Solution

by:
blkline earned 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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