LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2010, 12:51 AM   #1
farnaw4u
Member
 
Registered: Aug 2006
Posts: 38

Rep: Reputation: 15
how to schedule a script in linux


Hi

i have oracle installed on Linux i want to schedule a script "backup.sh" to run in oracle user.



oracle@linux1]crontab -e
*/2 * * * * /tmp/backup.sh

this script does not execute by cron.

BUT

oracle@linux1 tmp] ./backup.sh ------executes successfully


I dont know why the script is not being executed by cron


kindly help me
 
Old 03-06-2010, 01:37 AM   #2
nodopro
Member
 
Registered: Oct 2008
Posts: 48

Rep: Reputation: 16
Make sure crond service is running.
Code:
# service crond status
crond (pid  2775) is running...
 
Old 03-06-2010, 01:42 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
If even cron is running, try this

bash /tmp/backup.sh in the cron file.
 
Old 03-07-2010, 02:27 PM   #4
giammy
Member
 
Registered: Feb 2010
Posts: 36

Rep: Reputation: 20
Quote:
Originally Posted by farnaw4u View Post
Hi
...

I dont know why the script is not being executed by cron

kindly help me
Hi,

please, remember that cron commands are executed with a different
environment: for example you do not have the PATH, so commands that
are found from command line are not found from cron.

Just a supposition!

bye
giammy
 
Old 03-07-2010, 02:55 PM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
To test, create a simple script which will create a file .
make sure to give the whole path to the commands and files.
See if it works.
Then you know the problem is the script, not cron
 
Old 03-07-2010, 07:31 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
show the script content; also if it has an error either the cron job owner or root should get an email from cron re any errors. Try

mailx

from the cmd line as owner and as root to see.
Also, check /var/log/messages.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to schedule to run a script? ArthurHuang Programming 2 05-22-2009 02:30 AM
Using crontab to schedule a script stuball Linux - Server 9 05-19-2009 08:39 AM
Schedule a script to run philipo Slackware 3 06-22-2007 06:10 PM
Schedule a Script to Run nutthick Linux - Newbie 8 02-02-2005 01:37 PM
Schedule a script every three hours dkochan Linux - General 1 03-07-2004 11:18 AM


All times are GMT -5. The time now is 01:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration