How to add a script to Crontab?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add a script to Crontab?
# 1  
Old 02-17-2011
How to add a script to Crontab?

Hi!

We are on AIX 5.3

I have a script that must be run once every hour.

How do i add this to the crontab?

I know how to access crontab which is, crontab -e.

What do i do after that ? If i have the path to the script?

Thank you!!!
# 2  
Old 02-17-2011
Add a line like this:

Code:
0 * * * * /path/to/script.sh

This will tell cron to run /path/to/script.sh on minute 0 of every hour, day, month, and weekday.

If the script doesn't run quite properly from cron, it's probably because cron's default PATH is much more minimal than a user would have, either hardcode a sane PATH in the script (export PATH="...") or read in /etc/profile with . /etc/profile
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-17-2011
I only guess this code but i am glad you confirmed it.

So is the command "crontab -e " correct ? to enter that code to schedule the script?

After that if i want to make changes to that script how do it do that ?

Thanks for all your help!
# 4  
Old 02-17-2011
Quote:
Originally Posted by atechcorp
I only guess this code but i am glad you confirmed it.

So is the command "crontab -e " correct ? to enter that code to schedule the script?

After that if i want to make changes to that script how do it do that ?

Thanks for all your help!
Then you crontab -e again and change the settings to what you want for it (edit the line).
This User Gave Thanks to mrwatkin For This Post:
# 5  
Old 02-17-2011
Thank you! All my concerns are cleared

Last edited by atechcorp; 02-17-2011 at 02:31 PM..
This User Gave Thanks to atechcorp For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Crontab in script

I have crontab setup via crontab -e I was wondering if its possible to create a cron job from a script so when the script is run the cron job is created? (3 Replies)
Discussion started by: scriptnewbie
3 Replies

2. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when... (6 Replies)
Discussion started by: G30
6 Replies

3. UNIX for Dummies Questions & Answers

crontab script

Hi guys Can someone help me with a crontab script please? I have to sort the files from /bin and put the first 3 of then (with size and path) in /home/user/bin_size i write the command: find /bin/ | xargs ls -lS | awk 'FNR<4{print($5, $9)}' > /home/user/bin_size which is working but when I... (2 Replies)
Discussion started by: G30
2 Replies

4. Shell Programming and Scripting

crontab script

Hi All, I am running a script to find the CPU and memory utilization of the server. Script name is atul. When i run this script then it gives the desired output as DATE, CPU and MEMORY utilization....as mentioned below: $ $ cat atul A=`date| cut -d" " -f1-4; top -d 1 -n 1 | awk '/^CPU... (5 Replies)
Discussion started by: atulbassi83
5 Replies

5. Solaris

cannot add PATH to user crontab file

hi All, here is the problem: I'm not able to specify a PATH inside the user crontab file (/var/spool/cron/crontabs). The only syntax it accepts is the usual "* * * * * file" I'm not able to add PATH, or HOME, or MAILTO, or anything else. when I try to save the crontab, I have the error: ... (1 Reply)
Discussion started by: joe_x
1 Replies

6. Solaris

pl script in crontab

Hi I have successfukky created a sh script that runs perfectly well when run. It contains within a pl script that when run through a crontab will not run. Are there restrictions running a pl in cron? (14 Replies)
Discussion started by: rob171171
14 Replies

7. Shell Programming and Scripting

How to add cron job in /etc/crontab

Hi, How to add a cron job in /etc/crontab using a shell script.??:confused: Actually the requirement is we need to run a script say, XXX.sh every 10 min through “cron”. That can be achieved by adding the below code line in the /etc/crontab , (i.e., “crontab -e ” command to add this to the... (4 Replies)
Discussion started by: Dedeepthi
4 Replies

8. Solaris

Add item to crontab

hi, how can I add a new value to crontab file using a script not using the command " crontab -e " . ex: echo " 10 10 * * * " >> /var/spoll/cron/crontabs/<username> how can I do that in a correct way?? thanks, (3 Replies)
Discussion started by: Ahmed waheed
3 Replies

9. Shell Programming and Scripting

Crontab a Script

I know my question maybe eazy, but it realy cause a problem for me I have a Perl script to run and get some output, I run this script using perl /moutaz/ciscolog/telnet.pl I made another script as follow:(/moutaz/ciscolog/script) #!/bin/bash perl /moutaz/ciscolog/telnet.pl cp... (6 Replies)
Discussion started by: moutaz1983
6 Replies

10. Shell Programming and Scripting

how can i use crontab in a script?

hi.. i wolud like to know if it´s possible use the crontab command in my script. the idea is what the script starts automatically, but i don´t know how to do it. please, help me.... thanks jonathan (1 Reply)
Discussion started by: DebianJ
1 Replies
Login or Register to Ask a Question