Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

crontab not working as expected on SuSE linux

Posted on 2004-09-24
7
Medium Priority
?
780 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

609 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