What does /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh do?
How long does /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh run?
Do you want /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh to run, then sleep for 30 seconds, and run it again; or do you want to run /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh every 30 seconds even if each invocation runs for an hour?
You could try something like:
Since you chose not to show us your script, we have no idea how many processes it runs nor whether or not it is designed to allow multiple copies of itself to run simultaneously without destroying each other's data. Depending on how many minutes few minutes is and how many processes each invocation of /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh starts, you could run out of process table slots allowed for your user ID. And, if the system you're running on has other users that want to do something, a script like the above will be put to sleep to allow other users (or other things you want to run) to run if you become a CPU hog or a disk hog, or a network hog, etc. and some of your sleep 30 commands may take (a little or a lot) more than 30 seconds to complete.
Depending on what operating system you're using and what your script does there may be utilities provided by your operating system that can watch files (individually, in groups, all files in a directory, or all files in a file hierarchy) that will be MUCH more efficient than running 2 * few copies of a process simultaneously.
Last edited by Don Cragun; 08-18-2016 at 07:58 PM..
Reason: Add missing "&" to "wait".
My gut feeling tells me that you are not really wanting to have a new instance of the script started every 30 seconds regardless of how long it runs, but here you go:
Simply put two lines into your crontab:
I hope this helps.
bakunin
These 2 Users Gave Thanks to bakunin For This Post:
My gut feeling tells me that you are not really wanting to have a new instance of the script started every 30 seconds regardless of how long it runs, but here you go:
Simply put two lines into your crontab:
I hope this helps.
bakunin
Hi bakunin,
I agree that running multiple copies of a script (that from its name) we assume watches for filesystem changes seems like a bad idea.
Hi prats_7678,
Note that cron also places limits on the number of cron, at, and batch jobs it will run simultaneously. If you run into this limit (and you aren't the only user on your system), you may have groups of irate users asking your sysadmin to kick you off of your system or to lower the priority of all processes that you run.
And, there is no guarantee that jobs scheduled by cron won't be delayed. If system load is high, cron won't start jobs until the load drops. If that happens, cron might end up starting several of your delayed jobs within milliseconds of each other.
We would much prefer that you explain to us what you are trying to do and give us details about the system you're using so we can help you find an efficient way to get the job done rather than keeping us in the dark and asking us to teach you how to be a resource hog.
These 2 Users Gave Thanks to Don Cragun For This Post:
Hi,
I have developed a file deletion script and scheduled it in cronjob to run daily at 5:00 AM. But the script is not running automatically any day. However when I run the script manually at any time, it runs successfully. This is how the cron looks like :
0 5 * * *... (5 Replies)
I have a script that backs up a directory, creates a log file and mails the log file to us.
find . -print | backup -ivqf/dev/rmt0 | tee backup.log
cat backup.log|mail -v -s "Tape backup log" maillist
This script works fine from the console.
When I schedule it in cron, I never get the... (1 Reply)
All,
Running the below script independently is working fine with no issue but once I am scheduling it in cron on my Linux environment it is not working.
Can anyone look into this and let me know what I have to modify here to schedule it properly.
09 03 * * 4 ksh 'cd... (1 Reply)
Hi,
I need to schedule a script in crontab which should run at 01:00 am in the morning and should run for every 15 days in a month.
How to schedule this by using crontab?
Many thanks.
Rgds, (13 Replies)
Hi,
How can we run/schedule a shell script. Since there is no access to cron at this point of time we have to think other way out to run a script every hour.
How can we achieve this. Need advice.
How about using sleep,autosys etc...the script should trigger off every hour...which sends... (3 Replies)
Hi guys,
I am new guy for unix. I need help writing the following shell script.
My requirement is:
I have few pl/sql procedures(lets say 10). I want to run some of them (say 5) parallally in the background and once these are completed trigger the next ones one after other.
Could some one... (13 Replies)
Hi,
Before I start, I would like to inform that, I went through all FAQs and other threads before posting here.
I 'm trying to schedule a shell script on cygwin using cron. No matter what I do I don't seem to get the cron job executing my bash script.
My script is temp.sh
echo `date` >... (4 Replies)
Hi,
I have a ksh scrip (x) that scans a directory and does actions when a file arrives in this directory.
My question is what is the best way to schedule x?
1. Use cron tab and create a task running forever
2. Creat another ksh script (y) that runs (x) in a non-terminating loop
Which... (2 Replies)
Hi everyone,
I am trying to automate one process on Solaris OS.
This is what happens at the moment.
Every night at 19:30 and every hour after that we run a script that checks the status of databases. That script runs and prints if db's are OK at the end it states how many were down.
I am... (3 Replies)