LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-28-2006, 08:57 AM   #1
shendeswanand
LQ Newbie
 
Registered: Dec 2005
Posts: 11

Rep: Reputation: 0
Question crontab


Hi friends,
i am Swanand. I am just trying to know linux now. I am faced with a problem. I am trying to schedule a program using cron. But i am not able to schedule it.
I was logged in as user root. Then i made a file in the directory /etc/cron.d named myfile, and wrote the following things :
--------------------------------------------------------
SHELL=/bin/bash
#PATH=/root:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

01 * * * * root echo "yahoo!"
--------------------------------------------------------

But i received a mail and when i checked it, it showed :

From root@localhost.localdomain Sat Jan 28 20:01:05 2006
Return-Path: <root@localhost.localdomain>
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by localhost.localdomain (8.13.1/8.13.1) with ESMTP id k0SEV37t004890
for <root@localhost.localdomain>; Sat, 28 Jan 2006 20:01:04 +0530
Received: (from root@localhost)
by localhost.localdomain (8.13.1/8.13.1/Submit) id k0SEV2Lb004888;
Sat, 28 Jan 2006 20:01:03 +0530
Date: Sat, 28 Jan 2006 20:01:03 +0530
Message-Id: <200601281431.k0SEV2Lb004888@localhost.localdomain>
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <root@localhost> root rm /root/testcron.txt
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/root:/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
-----------------------------------------------------
Can anyone please tell me how to schedule the jobs using cron ????
Thank you.
 
Old 01-28-2006, 09:25 AM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Not sure what you are doing but it if that is the entire file it should have something like this at the beginning.
#!/bin/bash
#!/bin/csh
All depends on what shell enviroment you need it to use. Also needs to executable. Run the command ' chmod +x name_of_file '.

Hope this helps
Brian1
 
Old 01-28-2006, 09:35 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It told you at the end:
Quote:
/bin/bash: root: command not found
It is saying you tried to execute a command named "root" but it couldn't be found.

Quote:
01 * * * * root echo "yahoo!"
The above appears to be valid syntax for a file in cron.d but NOT for a line in crontab. You didn't try to add it to your crontab as well did you? As root type "crontab -l" to verify you don't have that line in crontab itself - if you do then type "crontab -e" and delete the line. You should have EITHER a file in cron.d OR a line in crontab - not both.

Another issue though - 'echo "yahoo!"' has nowhere to output - remember this is being done in the background - not by your terminal or console. It "might" put it on the console but if it were me I'd specify an output rather than leaving it like that e.g.:

echo "yahoo!" >/dev/console
 
  


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
crontab ashley75 Linux - General 3 07-21-2005 10:48 AM
crontab mytinytown Linux - Newbie 3 02-17-2005 07:38 AM
new to crontab desbyleo Solaris / OpenSolaris 15 12-16-2004 03:04 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
crontab alaios Linux - General 5 05-01-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:14 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