LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 01-27-2006, 11:09 PM   #1
ahmedb72
Member
 
Registered: Jan 2006
Location: Sydney
Distribution: RHEL
Posts: 72

Rep: Reputation: 15
problem with using cron utility


Hi all,
I have a problem in using cron utility.

Here's the steps I followed as root user:

# crontab -u root /etc/crontab
# crontab -e


then I edited the crontab as follows:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
1-59 * * * * root run-parts /usr/bin/w >> /ws.log
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


as shown this should write output of w command into /ws.log file.

I waited for a minute then I got email with the following output:

From root@localhost.localdomain Thu Jan 26 18:46:02 2006
Date: Thu, 26 Jan 2006 18:46:01 +0400
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <root@pc2> root run-parts /usr/bin/w >> /ws.log
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>

/bin/bash: root: command not found


Obviously the command didn't work.

I also re-edited the crontab as follows:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
1-59 * * * * /usr/bin/w >> /ws.log


still I had the same problem.

Any help will be appreciated.
 
Old 01-28-2006, 04:39 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
It looks like you've copied the main crontab file (/etc/crontab) into your crontab with crontab -u root /etc/crontab. Ignoring that for now though...

The run-parts command is for running all of the cron scripts in a directory and you don't need it to run a single command. You should be able to make it work by changing the line:

Code:
1-59 * * * * root run-parts /usr/bin/w >> /ws.log
to:

Code:
1-59 * * * * (/usr/bin/w >> /var/log/ws.log)
 
Old 01-30-2006, 02:27 AM   #3
ahmedb72
Member
 
Registered: Jan 2006
Location: Sydney
Distribution: RHEL
Posts: 72

Original Poster
Rep: Reputation: 15
Hi gilead,

your idea resolved the issue. Thanks alot.
 
Old 01-30-2006, 12:44 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
No problem - glad it worked
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Problem loading cisco WIFI utility? frankie_fix Linux - Software 1 02-15-2005 10:18 AM
Cron problem vasco1984 Linux - Software 5 11-22-2003 11:07 AM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration