Run script every minute and terminate after specified number of executions

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run script every minute and terminate after specified number of executions
# 8  
Old 02-03-2014
Don't have it started by cron every minute. Run it once, execute a loop 10 times, sleep for not quite a minute in that loop, and exit gracefully.

And, why don't you give us a broader picture of what you want to achive? We might be able to help you better, then, instead of supplying bits and pieces here and there...
# 9  
Old 02-04-2014

Last edited by azherkn3; 02-04-2014 at 05:46 AM..
# 10  
Old 02-04-2014
If I understand what is going on in this thread, you have changed references in your script to use absolute pathnames when your read and write samp.csv, but it sounds like you are not using an absolute pathname when you read and write a.log. Unless you add a cd command at the start of your script to move into the directory where all of these files reside, you have to use absolute pathnames in all references to all input and output files.

How are you initializing the contents of /full/path/to/a.log?
# 11  
Old 02-04-2014

Last edited by azherkn3; 02-04-2014 at 05:47 AM..
# 12  
Old 02-04-2014
Did you really do what clx suggested? Or did you only remove the let?
Here is another one
read run < a.log
echo $(( $run + 1 )) > a.log

# 13  
Old 02-04-2014
It's nearly always best to use the absolute path name in scripts, for all filenames, including commands.

First of all, if you don't use a full path, then it's possible another file can be executed that is in the search path; and this can cause numerous problems, including security issues.

Second, if you refuse (for some odd reason), to use the full path name, you should define your search path explicitly in the script, for the same reasons.

In this example, the poster is writing from cron as a user that he has not defined (for us). It's possible he could be running it as a root crontab.

The original poster should rewrite the script using the full path to all files (commands, logs, input files, etc.) and he should inform what user crontab is running this script.

He should also list each file that is read and written to with ls -l so we can see the permissions of the files.

i think it is best when working the problems to get the correct and full information instead of just grasping at straws and pulling bits and pieces of information from the member with the problem.

The user will also learn more, I think, if we ask them to provide the right information up front, define his paths correctly (all paths), etc. .. in my view.
This User Gave Thanks to Neo For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a shell script in a loop with max number of threads

hi guys. i have a question for you i have a one file and inside this file there are 1000 lines and each line is a linux command running this commands takes long time so i want to create one bash script and run this lines in a loop with max number of threads for example i want to run... (2 Replies)
Discussion started by: avtaritet
2 Replies

2. Shell Programming and Scripting

How to use counter to run the script to limit number?

I want to run my shell script to the limit number.Suppose I know in advance that MAX=5 then I want that my script run 5 times only.Something like below$ vi testingMAX=5COMMAND=&quot;ssh -l stpuser VHLDVWSAD001 /projects/st/utils/deploy/ >/dev/null 2>&1 &&quot; ; sleep 20;count=0while... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

3. Shell Programming and Scripting

Pausing between two executions in a shell script

HI, Please help me on this. I have to execute 100 scripts which i have redirected in to a file . I want to pause the script after first execution and once i say enter key word it has to go to next execution. My looks like for RUNFILES in `cat ${SOURCEFILES}/scripts` do echo $RUNFILES; ... (1 Reply)
Discussion started by: srichunduru
1 Replies

4. UNIX for Dummies Questions & Answers

Cannot run crontab :1: bad minute error

Hi can any one help me out. while running crontab , m getting error bad minute time.. how to resolve this error. i created 1 txt file a.cron mirrordir -vm \home\t \homet1 & i saved it. then i created a crontab file ..with crontab -e & i added a line in it. * 1 * * * \root\a.cron & i save... (2 Replies)
Discussion started by: unxdost114
2 Replies

5. Shell Programming and Scripting

tcsh: not run script (if: Badly formed number)

Hello I have Linux Debian & tcsh shell. My mini script not run :(. Startup script displays a message: user@host:dir% ./test if: Badly formed number. script: #!/bin/tcsh -f #script check size files systems set x = `df -h /usr | tail -n1 | awk '{ print( $5 ); }'` set y = 60% if ($x... (5 Replies)
Discussion started by: moskovets
5 Replies

6. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

7. Shell Programming and Scripting

Ksh Script to get the start minute of n number of process

How can i write a script.? which lists all X process and gets the start minute of each of them. thanks (1 Reply)
Discussion started by: Anteus
1 Replies

8. Shell Programming and Scripting

run script 1 minute interval without CronTab

I am using Solaris 9. I wish to run my script every 1 minute inteval. Though i can run it using below entry in crontab. * * * * /export/home/username/script/file_exist_& in short above script will check whether a specific file exist in a directory. If it found it will inovke another... (10 Replies)
Discussion started by: thepurple
10 Replies

9. Programming

how can i run a process for a whole minute?

here's the problem, i have two processes that i need to run and both process should be run at a total of 1 minute each. how do i do that? and one more here's what the processes do: the 1st process show the '+" sign infinitely while the 2nd process displays the "-" infinitely. how could i count the... (1 Reply)
Discussion started by: kelogs1347
1 Replies

10. Shell Programming and Scripting

Terminate session on completing script

Hai all.. How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The... (4 Replies)
Discussion started by: deepsteptom
4 Replies
Login or Register to Ask a Question