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
# 8  
Old 12-29-2008
Hi Danmero,

i run this below while loop--

#!/usr/bin/bash

while :
do
/export/home/username/script/file_exist_&_run.sh
sleep 60
done

its working fine.

and here is the snapshot of ps -ef. it continously remain.

bash-2.05$ ps -ef |grep while
ablbatch 29238 1 0 12:01:42 ? 0:00 /usr/bin/bash ./whileloop.sh
ablbatch 29628 28071 0 12:09:46 pts/7 0:00 grep while

as whileloop continously remain as process i hope it will not effect the system.. But main problem is user is getting mail evry 1 minute when there is no txt file. I really need to stop the mail. HOW TO??

Your expert comment is highly desirable to me

//purple

Last edited by thepurple; 12-29-2008 at 04:51 AM..
# 9  
Old 12-29-2008
Quote:
Originally Posted by thepurple
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.
If no mail should be sent if there is no file in the specific directory, then mail generation should be controlled then.

something like

Code:
ls file* 2>/dev/null 1 > &2
if [ $? -eq 0 ]
then
  echo "file(s) available"
  # send mail to receipient(s)
  # do the required operation
else
  echo "no such file(s) available"
  # do required operation or don't do anything
fi

# 10  
Old 12-29-2008
I do NOT wish to sendmail to recipient either existense of file or not.

My idea is user put a file in directory. Then system will check whether the specific file (say *.txt) is in there. If then run a particualr script.

meanhwile if [ $? -eq 0 ] --? what does it mean?
# 11  
Old 12-29-2008
Quote:
Originally Posted by thepurple
I do NOT wish to sendmail to recipient either existense of file or not.

My idea is user put a file in directory. Then system will check whether the specific file (say *.txt) is in there. If then run a particualr script.

meanhwile if [ $? -eq 0 ] --? what does it mean?
This is what you had posted
Quote:
But main problem is user is getting mail evry 1 minute when there is no txt file
I gave the reply/pointers based on what you had posted and I do not wish/intend to change the logic that you have in mind. Smilie

if [ $? -eq 0 ]

-- checks if the last executed command is a successful one or not
0 - means success
other numbers - corresponding error codes
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