run script 1 minute interval without CronTab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting run script 1 minute interval without CronTab
# 1  
Old 12-27-2008
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_&_run.sh

in short above script will check whether a specific file exist in a directory. If it found it will inovke another script to execute.

In fact, when a user will put a specific file in a directory only then it will execute. However, this will occur less



one of the experts advise better use daemon-like script or 'at' command which will be in loop....something like that Rather using shortinterval script in Crontab?

Experts could you please help me to get the dameon-like script for 1 minute interval..??
//purple
# 2  
Old 12-27-2008
Code:
while :
do
 # do something here
 sleep 60
done

# 3  
Old 12-27-2008
Hi Danmero,

Well i will put my script in #do something here.. Then I will run your script manually and will it be running contineously??

while :
do
# do something here
sleep 60
done

Another thing... do you think is there any possiblity of facing problem if i run the script in crontab by 1 minute interval? why short interval is not recommended in crontab?
# 4  
Old 12-27-2008
Quote:
Originally Posted by thepurple
Hi Danmero,

Well i will put my script in #do something here.. Then I will run your script manually and will it be running contineously??

while :
do
# do something here
sleep 60
done

Another thing... do you think is there any possiblity of facing problem if i run the script in crontab by 1 minute interval? why short interval is not recommended in crontab?
Why do you think short internal is not recommended in crontab? Any reason for that?

If such short interval is not recommended then an approximate granularity would be already provided by cron implementation itself and as far as I know there is no specification that short interval is not recommended.

With an ever running daemon dedicated for each and every such process, will consume more resources and its not an optimized approach unlike the usage of cron entries.

Using cron is clean, easy to modify, maintain and only one daemon cron-d runs all the time and the actual processes that are kicked off are just cron-d instance spawned and exec'd as the process mentioned in the cron-entry
# 5  
Old 12-28-2008
Quote:
Originally Posted by thepurple
Hi Danmero,

Well i will put my script in #do something here.. Then I will run your script manually and will it be running contineously??
Yes

Quote:
Originally Posted by thepurple
Another thing... do you think is there any possiblity of facing problem if i run the script in crontab by 1 minute interval? why short interval is not recommended in crontab?
Yes, if you start a process and the process don't finish in one minute the cron will start a second process and another one until ...
# 6  
Old 12-28-2008
Quote:
Yes, if you start a process and the process don't finish in one minute the cron will start a second process and another one until ...
And this should be controlled by implementing same-instance check in the process itself or best by a generic wrapper

or to implement logic based on lock file such that at any point of time in a host only one instance of process 'p1' runs
# 7  
Old 12-29-2008
Well, I tried put the script in Crontab for 1 minute interval- as i said the script check whether a specific file exist in a directory. If it found it will inovke another script to execute.
* * * * /export/home/username/script/file_exist_&_run.sh

In fact, whenever a user will put a specific file in a directory only then it will execute. However, user will put the file rare.

so every 1 minute a mail is generated and goes to user(/var/mail/...) mail box. How to stop that mail. otherwise it consumes lotof space and important mail will be missed.

in mail produced the following output:

*.txt: No such file or directory

So, crontab is not good for my purpose....any suggestion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run Bash Script thrice & then interval for 10 mins.

Hi... I am very new to shell scripting. I have written a script with help of this forum and some googling and it works the way I want it to. Currently this script checks for my SIP trunk registration every 5 seconds, if registration is not available then it reboots my router through telnet... (4 Replies)
Discussion started by: jeetz
4 Replies

2. Shell Programming and Scripting

Run script every minute and terminate after specified number of executions

when it runs and look at my acron.log file it generates an error as below /tmp/prog.sh: line 4: (12 Replies)
Discussion started by: azherkn3
12 Replies

3. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

4. Shell Programming and Scripting

Main script triggers second and it has to run at specific interval

Hi Friends, I am newbie to shell programming and I am stuck trying to accomplish following task.We use Bamboo CI which executes script1 passing parameters. This Main script executes script2 as backend process as part of one of it statements. Task of script2 is to essentially check whether a... (0 Replies)
Discussion started by: aditya206
0 Replies

5. Shell Programming and Scripting

How to run a script everyday between 7 and 8 pm with the time interval of 5 minutes?

Hi, Can someone help me in running a cronjob everyday between 7 and 8 pm with the time interval of 5 minutes in between to repeat that script. The script is so small and I need that to run daily between this time. Please if possible provide me the syntax for this logic. Thanks. (4 Replies)
Discussion started by: cya
4 Replies

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

7. AIX

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

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh 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

8. UNIX for Dummies Questions & Answers

Run script in the background with a time interval

I have a script I want to run in the background, and I have looked it up but I am not exactly sure how to do. First of all to run it in the background do you have to put something in the script or is it just a command when you go to run it. I found this solution to it but once again I am not to... (2 Replies)
Discussion started by: mauler123
2 Replies

9. Shell Programming and Scripting

script to run repeatedly after a fixed interval of time

Hi , I am working on the following script . I want this script to run and scan the log file repeatedly after 3 hours. This script will run & scan just for the current date logs and after every 3 hours. Kindly advice what to add in this script for this purpose. #!/bin/sh diff common.log... (3 Replies)
Discussion started by: himvat
3 Replies

10. Shell Programming and Scripting

Shell Script Run Interval to be dynamic

Hi All. I have a script which has to be run periodically. The frequency of its run will be decided by a Database stored value PollRate. e.g. If PollRate value is 300secs, then the script should be executed every 5 minutes, if it's 1500secs, it should execute every 15 minutes. Is there... (5 Replies)
Discussion started by: rahulrathod
5 Replies
Login or Register to Ask a Question