The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
i want a script to execute if the time is 12:00 automatically lakshmananindia UNIX for Advanced & Expert Users 2 09-04-2007 05:22 PM
Can we launch a shell script automatically upon ssh login? rockysfr UNIX for Advanced & Expert Users 1 07-02-2007 11:48 PM
how to run a Script automatically hamsa UNIX for Dummies Questions & Answers 4 10-18-2006 05:09 PM
Script to automatically change password. rahulrathod Shell Programming and Scripting 1 10-04-2004 09:33 AM
Script to find PID and kill automatically ST2000 Shell Programming and Scripting 4 08-01-2002 11:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-30-2001
arunava_maity arunava_maity is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 17
Unhappy

Hi All,
How to run a script automatically using cronjob everyday from Monday to Friday 9A.M to 5P.M at an interval of ONE HOUR.I want the complete syntax means how to put in the cron job and there after.
URGENTLY NEED HELP
THANKS IN ADVANCE
CHEERS
Arunava
  #2 (permalink)  
Old 04-30-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
#Format is:
# MIN HOUR DAY MONTH DAY_OF_WEEK COMMAND
# where DAY_OF_WEEK is 0-6, 0=Sunday
0 9-17 * * 1-5 your_command

  #3 (permalink)  
Old 04-30-2001
98_1LE 98_1LE is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2000
Location: Greater Dallas area
Posts: 405
To enter the above data that PxT shared, you can type 'crontab -e' and edit the file. If it opens it in an unknown editor, set your EDITOR variable to vi or another editor. You can also put the entry in an arbitrary flat file and execute
crontab flat_file
  #4 (permalink)  
Old 05-01-2001
arunava_maity arunava_maity is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 17
Thanks for the reply .
So if i want to execute my file eith the name myfile.sh everyweekday at an interval of one hour from 9 a.m. to 5 p.m. will the command be
0 9-17 * * 1-5 myfile.sh
[ can we give a path here like /mydir/myfile.sh]
Also how do u put the entire thing using crontab command.
I will like to know the detail syntax.
Bye
Thanks in advance
Cheers
Arunava
  #5 (permalink)  
Old 05-01-2001
98_1LE 98_1LE is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2000
Location: Greater Dallas area
Posts: 405
The easiest way is to create a text file named /tmp/myfile.sh.cron (name and location are relative and do not matter) with your cron statement in it:

Code:
0 9-17 * * 1-5 /home/user/bin/myfile.sh

You should always put the full path to the file in the crontab and a shell script as your PATH variable may not be what you think it is. This entry will run the script as you described. Then logged in as the user you wish to run the program as, type:

Code:
crontab /tmp/myfile.sh.cron

You can the delete the myfile.sh.cron file. To verify that it read it in, type:

Code:
crontab -l

  #6 (permalink)  
Old 05-02-2001
arunava_maity arunava_maity is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 17
I am having problem when i am trying to execute my shell script .In the beginning of my script i am reading some parameter values from a parameter file. After that in this script i am calling an external sql script.
It gives an error message

grep: can't open parameter.txt
grep: can't open parameter.txt

Calling an external SQL script
/final/myscript.sh: mysql
.sh: not found

When i independently run my script there is no problem atall.

URGENTLY REQUIRE HELP

THANKS IN ADVANCE

Arunava
  #7 (permalink)  
Old 05-02-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
Quote:
grep: can't open parameter.txt
grep: can't open parameter.txt
Sounds like maybe your script is not changing to the correct directory. Cron will 'cd' to your home directory before it runs your script. If you need to access files in other directories make sure to use full path names in your script, or else issue a 'cd' command.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0