To stop execution in cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To stop execution in cron
# 1  
Old 01-30-2014
To stop execution in cron

hi guys
i have a question
my cron should start executing minute but it sould stop execute only i have tried tis
[CODE]10 * * * * /home/sample.sh >>
/data/band/cron_$(date+|%Y|m|d).log

Last edited by azherkn3; 02-04-2014 at 05:42 AM..
# 2  
Old 01-30-2014
You could count each execution and store it in a file. Use this execution counter to decide whether to proceed or not:
Code:
if [ -f "/tmp/exec_counter_$(date +%Y%m%d)" ]
then
        cnt=$( cat "/tmp/exec_counter_$(date +%Y%m%d)" )
        if [ $cnt -eq 10 ]
        then
                exit 1
        else
                (( cnt++ ))
                print "$cnt" > "/tmp/exec_counter_$(date +%Y%m%d)"
        fi
else
        print "1" > "/tmp/exec_counter_$(date +%Y%m%d)"
fi

This User Gave Thanks to Yoda For This Post:
# 3  
Old 01-30-2014
This may not be an adequate request for cron. Your entry will start at 10 min past each full hour and this will continue for ever and a day.
Try running a loop ten times and have a sleep 600 in there.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Stop script execution, when we encounter error

Team, Im new to shell scripting please help in below issue: Considering scenario i have 1.sql,2.sql,3.sql and 4.sql . If my second script fails my loop should come out and should not execute 3.sql and 4.sql. Here is my code. #! /bin/bash echo "exit" | user/password | grep Connected >... (4 Replies)
Discussion started by: preethi87
4 Replies

2. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

3. Solaris

How to stop a cron job?

Hi Guys. can someone please tell me how to stop a running cron job without editing the cron file? I know you have to find the process ID of the command, but I have no idea of how to do that. I will really appreciate it . Thanks (3 Replies)
Discussion started by: cjashu
3 Replies

4. Shell Programming and Scripting

Command to stop all the cron jobs

Hi All, Please provide the command to stop all the cron jobs. Thanks in Advance Regards, Sindu (2 Replies)
Discussion started by: indira_s
2 Replies

5. Shell Programming and Scripting

Stop execution of script if some condition fails

After my if condtion give rusult true then script should stop execution. Please advice...Thnaks in advance (1 Reply)
Discussion started by: vivek1489
1 Replies

6. Shell Programming and Scripting

how to stop execution of a script after one hour

I have a shell script that writes some data in a file. I want to stop the script after one hour from start of execution using "EXIT 1". how to do it. I don't want to use CRONTAB. (5 Replies)
Discussion started by: mady135
5 Replies

7. Linux

Why service (start|stop) can not be called from cron?

Hi, When I googled, I came to know that I can not call the command "service <service-name> start" from cron, insted I have to specify path to the service-name. I wanted to know the reason. Thanks, Hansini (3 Replies)
Discussion started by: hansini
3 Replies

8. Solaris

How to start/stop cron jobs on live server

Hi, I am working with a company where some times i need to start/stop cron jobs on need basis. I have one option to kill cron daemon.Is it right? Please correct me. Waiting for your reply. Thanks in advance.. (2 Replies)
Discussion started by: varaprasadu
2 Replies

9. Programming

how to stop execution in for loop

Hi all, I am working on a c source code nearly 2000 line . it contains one big for( i=0; i< 200 ; i++ ) loop of around 600 lines could any tell me how to break the execution of prog when the value of i is 50 in for loop so that i can check inside the loop. Thanks.. (1 Reply)
Discussion started by: useless79
1 Replies

10. UNIX for Dummies Questions & Answers

temporarily stop cron services

hi can i know what is the command and in which directory to temporarily stop the cron service of my server? here is my server information thanks SunOS statsfs07 5.8 Generic_117000-03 sun4u sparc SUNW,Ultra-4 (1 Reply)
Discussion started by: legato
1 Replies
Login or Register to Ask a Question