LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-05-2010, 11:51 PM   #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, 12: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, 12:42 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

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

bash /tmp/backup.sh in the cron file.
 
Old 03-07-2010, 01: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, 01:55 PM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
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, 06:31 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:28 AM.

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