Cron job not executing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron job not executing
# 1  
Old 02-21-2011
Cron job not executing

I need to add 10 records to database from a file /tmp/authlist.log(contains insert into table sql commands)

When i execute the following script manually its executing and working fine.
the same is not getting executed when i try to execute using crontab

PHP Code:
vi /tmp/test1.sh

#!/bin/sh
logfile=/tmp/authlist.log
mysqlauth
=/tmp/mysqlauth.log
rm 
-rf $mysqlauth 1> /dev/null 2>&1
touch $mysqlauth
head 
-5 $logfile $mysqlauth
#sed -i '1,5d' $logfile > logfile
exec $mysqlauth
while read line
do
mysql -uroot -ppassword kalyan -"$line"
done 

PHP Code:
crontab --u root
42 3 
* * * root /tmp/test1.sh 
PHP Code:
[root@localhost ~]# crontab -l -u root
42 3 * * * root /tmp/test1.sh 
Please let me know where i have committed mistake
# 2  
Old 02-21-2011
Check the permission of the script . The script should have executable permission.
# 3  
Old 02-21-2011
The script has 755 permission

-rwxr-xr-x 1 root root 270 2011-02-21 03:36 test1.sh
# 4  
Old 02-21-2011
My guess is that your probably not finding mysql or something you need
that's called in your script.

Try changing your crontab entry to something like this to set what
you need in order to execute your script.

20 20 * * 6 SHELL=/usr/bin/ksh; export SHELL; . $HOME/.profile; /tmp/script.ksh > /tmp/script.out 2>&1

I would also place a "set -x" in your script to see where its failing. The
script execution path will than be placed in /tmp/script.out and that may
give you a clue to what's going on.
# 5  
Old 02-21-2011
I think you have your cron entry incorrect:-
Code:
crontab -l -u root 
42 3 * * * root /tmp/test1.sh

This states that at 03:42 every day, the following command is run:
Code:
root /tmp/test1.sh

so unless you have a command called root then this will fail to even start. If you are expecting this to nominate the user to run the command, then that is set by the fact that it is in root's crontab file.

Does this help?


Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Executing a job with file success

Hello All, I have a scenario where I need suggestion I am creating a file watcher job on autosys and and command job to do a SCP a file from one server to another. My file watcher will get success once the file get receive. The file I am receiving a zip file. THe command job which I am... (4 Replies)
Discussion started by: arunkumar_mca
4 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. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

5. UNIX for Dummies Questions & Answers

Executing python scripts via cron job

Hi, I'm executing a python script via cron job. The way it is set up is, I'm editing a file called local00 22 * * * root su - -c "/opt/setup_dir/bin/run_bkp -p" When this job executes, the command-specific logfile and the syslog (where the logs are supposed to go) show half of the logs(no... (2 Replies)
Discussion started by: ashwini.engr07
2 Replies

6. UNIX for Dummies Questions & Answers

nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background. nohup perf_mon -c rating_4_multi,cfg & The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I... (2 Replies)
Discussion started by: ido1957
2 Replies

7. UNIX for Dummies Questions & Answers

Problem with executing command inside a cron job

Hi All, I have scheduled a script in cron which writes output to the below file. ....>> /data/Target/wrapper_invoke_ds_job_`date '+%Y%m%d'`.ksh_out 2>&1 But the date command is not getting resolved in the format specified. It just resolves to the following. wrapper_invoke_MQ_ds_job_Tue... (3 Replies)
Discussion started by: pkm_oec
3 Replies

8. 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

9. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

10. Shell Programming and Scripting

executing a cron

Hi Gurus I have a requirement to execute a cron job every 30 min until 8pm in the night and again start at 8 am in the morning. How would I add the cron entry for this requirements. all inputs are appreciated. Thanks in advance (8 Replies)
Discussion started by: ragha81
8 Replies
Login or Register to Ask a Question