Adding a cron job that will execute everyday at 14:50 hrs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a cron job that will execute everyday at 14:50 hrs
# 1  
Old 07-03-2012
Adding a cron job that will execute everyday at 14:50 hrs

Hi
I want to execute a cron job everyday at 14:50 hrs. I have a script like this:

Code:
 TMP_FILE="/tmp/tmpcron.txt"
 RES=0
 /usr/bin/crontab -l >> $TMP_FILE
 ADD_JOB="50 14 * * * /opt/mypath/scriptname.sh"
 grep "scriptname.sh" $TMP_FILE >> /dev/null
 JOB_NOT_EXIST=$?
 if test $JOB_NOT_EXIST == 1
 then
        echo "$ADD_JOB" >> $TMP_FILE
        /usr/bin/crontab $TMP_FILE >> /dev/null
        RES=$?
 fi

 rm $TMP_FILE
 exit $RES

However it is not getting executed at 14:50 Hrs. Can anyone tell me what I am missing?

Last edited by methyl; 07-03-2012 at 07:21 AM.. Reason: please use code tags
# 2  
Old 07-03-2012
why do you add same lines after every execute your script
Code:
/usr/bin/crontab -l >> $TMP_FILE

change to this
Code:
/usr/bin/crontab -l > $TMP_FILE

and firstly check yur cron job list before execute ttyoru script and then execute your script,
after check your cron list for is there a line for "scriptname.sh"
# 3  
Old 07-03-2012
What Operating System and version do you have? What Shell are you using?

Try removing the redirect to /dev/null from the crontab command to see if there is any message.
Also try running crontab -l to see if the new entry made it into the crontab.
If the entry is in the crontab, then look for errors in unix mail for the owner of the crontab and in the cron log.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX cron job is running everyday instead of on a particular day

Hello, I was trying to run a script on a dev server using cron job. It supposed to run 3rd sunday of every month. 45 4 15-21 * 0 /home/user1/myscript.sh >/dev/null 2>&1 # run this script 3rd sunday of every month When I Schedule it on AIX server, It is running every day at 4:45 AM. am I... (3 Replies)
Discussion started by: Kumar7997
3 Replies

2. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

3. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

4. Shell Programming and Scripting

Been working since 25+ hrs: Bash Script to rename files supposedly direct but difficult to execute

:wall::wall::wall: Hi I have horrible script below, need help in renaming ls -l output into new filename format: Desired output: cp -pv original_path/.* newDirectory/owner_of_file.%dd%mm%y.file_extension.first_8_characters_of_original_filename localuser@localuser:~ vi... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

5. Shell Programming and Scripting

Adding a new root cron job

Hi there, I have over 2000 systems (mainly Solaris) and I want to write a script that inserts a new root cronjob on each of those servers. obviously just adding a line to /var/spool/cron/crontabs/root looks like the easiest way, but i really dont want to have to send a HUP to crond on all boxes ... (3 Replies)
Discussion started by: rethink
3 Replies

6. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

7. UNIX for Dummies Questions & Answers

a cron job needs a perl script to execute

Hello evreyone, this is my first post, and to say i'm new to this is an understatement. I know very little about perl scripts and hope some one can help me. i'm looking to get a script that a cron job can execute. what the script needs to to is 1) connect to a mysql database 2) go to a... (2 Replies)
Discussion started by: Exader
2 Replies

8. Shell Programming and Scripting

Shell script is taking more than 3 hrs to execute

Hi I am doing a process of converting all the values of key column into a row, for eg Key col1 col2 1 1 1 1 2 1 1 1 3 1 3 1 2 ... (2 Replies)
Discussion started by: nvuradi
2 Replies

9. UNIX for Dummies Questions & Answers

CRON job to execute all scripts in a directory

Hi everyone: I'm trying to make a CRON job that will execute Fridays at 7am. I have the following: * 7 * * 5 I've been studying up on CRON and I know to have this in a file and then "crontab filename.txt" to add it to the CRON job list. The CRON part I believe I understand, but I would... (6 Replies)
Discussion started by: Annorax
6 Replies

10. UNIX for Dummies Questions & Answers

Cron job -- to execute at every first Sunday of every month

Dear all How can I schedule the cronjob to be run sometime at every first Sunday at every month? I have the edit the cronjob every month now, thanks (2 Replies)
Discussion started by: shanemcmahon
2 Replies
Login or Register to Ask a Question