How to run a script automatically ?????

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to run a script automatically ?????
# 1  
Old 04-30-2001

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.
# 2  
Old 04-30-2001
#Format is:
# where DAY_OF_WEEK is 0-6, 0=Sunday
0 9-17 * * 1-5 your_command

# 3  
Old 04-30-2001
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  
Old 05-01-2001
Thanks for the reply .
So if i want to execute my file eith the name everyweekday at an interval of one hour from 9 a.m. to 5 p.m. will the command be
0 9-17 * * 1-5
[ can we give a path here like /mydir/]
Also how do u put the entire thing using crontab command.
I will like to know the detail syntax.
Thanks in advance
# 5  
Old 05-02-2001
The easiest way is to create a text file named /tmp/ (name and location are relative and do not matter) with your cron statement in it:
0 9-17 * * 1-5 /home/user/bin/

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:
crontab /tmp/

You can the delete the file. To verify that it read it in, type:
crontab -l

# 6  
Old 05-02-2001
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/ mysql
.sh: not found

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



# 7  
Old 05-02-2001
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a script before and after reboot automatically and send output to two locations.

Hello Team . I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are 1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ? 2. The same... (2 Replies)
Discussion started by: Varja
2 Replies

2. Shell Programming and Scripting

How to run script automatically every 12 hour once?

Hi ! all, I have once script to remove temporary cache and temporary xml files looks like this, as it is taking more space, I would like to run automatically every 12 hour once, and then I want to receive some log as acknowledgement #!/bin/sh echo "Removing logs and temp files (typically... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

3. Shell Programming and Scripting

How to run script automatically on reboot as root user?

Hi friends,,, I am running one server on Ubuntu 12.04 LTS 32-bit, some times my pc restarts automatically, with no reason, I have a script to start server which requires root password. in this directory /myserver/ How can I do this ? and some scripts I am having that I... (1 Reply)
Discussion started by: Akshay Hegde
1 Replies

4. AIX

How to run a script automatically when AIX version 7 server reboots?

Am new to AIX please help me. I have AIX7 server. When ever the system reboots my script need to run automatically. This will help me to start my application automatically after the server reboot. Thanks, Prince Wells (9 Replies)
Discussion started by: prince1987
9 Replies

5. Shell Programming and Scripting

variable has no value if run the script automatically/scheduled

Hi All, I am using ksh as the shell. I have a script that should store variable after executing "onstat" on informix. I can execute it successfully without any issue if run manually, however the value is not showing up when run automatically(scheduled). Is there anything needed to make the... (1 Reply)
Discussion started by: tungaw2004
1 Replies

6. Shell Programming and Scripting

How to run a script automatically

Hi All, How can i run a script every week automatically. Thanks & regards, Sam (5 Replies)
Discussion started by: sam25
5 Replies

7. Shell Programming and Scripting

Automatically run bash script

Hi! I want to run/execute a bash script automatically everytime when a specific file is created or when its timestamp changes. Is this possible? How? Thank you very much for your answers in advance, Regards, Christoph (1 Reply)
Discussion started by: ckofler
1 Replies

8. Shell Programming and Scripting

how to run shell script automatically

hi , i m trying to run bash scrip automaticially but i dont know how i can do this an anybody tell me how i can autorun shell script when i logon . thanks (9 Replies)
Discussion started by: tahir23
9 Replies

9. UNIX for Dummies Questions & Answers

how to run a Script automatically

How to make a script run automatically using a cron?? i do not know abt cron...... if i have file and i need this to run everyday at a particular time what needs to be done thanks in advance (4 Replies)
Discussion started by: hamsa
4 Replies
Login or Register to Ask a Question