1825766 Members
2196 Online
109687 Solutions
New Discussion

Re: cron

 
SOLVED
Go to solution
khilari
Regular Advisor

cron

Hi people. how r u. Okay this is what i did to configure my cron job and it didnt work.
vi /tmp/test2
1). find / -name core -print > /tmp/test1
2). chmod +x /tmp/test2
3). crontab -e
4). 30 10 * * * /tmp/test2.sh // i wanted it to run one time at 10:30.

What i was expecting was a file being created /tmp/test1 with the core files in it at 10:30. Can anyone tell me what went wrong???
7 REPLIES 7
Jeff_Traigle
Honored Contributor

Re: cron

If you did exactly those steps, you created the script with name "test2", but called it from cron as "test2.sh".
--
Jeff Traigle
Patrick Wallek
Honored Contributor

Re: cron

First, you vi '/tmp/test2' but your have '/tmp/test2/sh' in your cron entry. Was this just a typing error?

Second, maybe there weren't any core files on your system? What happens if you run that command from the command line? Do you get any results in the /tmp/test1 file?

Third, are you sure the statement ran? Check /var/adm/cron/log and see what the return code was for that script.
khilari
Regular Advisor

Re: cron

The file the cron is in is /tmp/test2 whose permissions have been changed to executabel, chmod +x /tmp/test2
/tmp/test1 is the file i want to send the output to, i ran the find / -name core -print command it worked on the shell. and now it 4:57 i wanted it to run at 5pm today only so below is the entry in the crontab
* 17 * * * /tmp/test2.sh
Jeff_Traigle
Honored Contributor

Re: cron

Like we both said... the script you created isn't the name you used in your crontab entry.

Either:

mv /tmp/test2 /tmp/test2.sh

or:

crontab -e
30 10 * * * /tmp/test2
--
Jeff Traigle
Patrick Wallek
Honored Contributor
Solution

Re: cron

2 things:

1) The name of the file MUST be the same in BOTH places. It must be either /tmp/test2.sh or /tmp/test2. You must be consistent. Either rename the file or edit your crontab entry as suggested above.

2) If you do '* 17 * * *' then your script will run EVERY MINUTE during the the 5PM hour (17:01, 17:02, etc.) If you just want at 17:00, then '0 17 * * *' is what you want.
Muthukumar_5
Honored Contributor

Re: cron

Use as,

#crontab -e
30 10 * * * /usr/bin/find / -name "core" -print > /tmp/test.out 2>/tmp/test.err

save it.

--
Muthu
Easy to suggest when don't know about the problem!
Yogeeraj_1
Honored Contributor

Re: cron

hi khilari,

you should add this "template" to your crontabs:

#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************


this will help you when setting the times of execution of your scripts!


above all, please check you scripts in isolation before putting it in your crontable!

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)