![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| infinite loop to check process is running | yabai | Shell Programming and Scripting | 12 | 10-23-2008 09:56 AM |
| the given code goes in infinite loop and does not increment variable i | mrityunjay22 | Shell Programming and Scripting | 6 | 12-26-2007 02:20 AM |
| Infinite Loop in Autosys while running a shell script, Manual run is fine | sharmagaurav_2k | Shell Programming and Scripting | 2 | 09-04-2007 08:20 AM |
| ls command in infinite Loop | umakant | SUN Solaris | 3 | 07-17-2007 01:25 AM |
| high priority thread contains an infinite loop | rvan | High Level Programming | 0 | 02-14-2007 09:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Running a script in INFINITE LOOP
Hi All,
I have a requirement as below. I supposed to get a file from Source system once in a month. But we dont know when the source system will send the file. My script has to wait for that file in LOOP once it gets the file then it has to FTP the file. I thought of scheduling the job once in a daily but "My requirement is to get the file ASAP else it will expire from the source system" So can any one suggest me the best solution for this? Thanks in Advance, Raamc. |
|
||||
|
I don't like loops. Why not have a cron job that runs every hour, checking for the presence of this file?
If once an hour isn't frequently enough, just do a script that runs in a loop and start it with "nohup" so it continues to run even when you log out. |
|
||||
|
Running the script for every hour by using the CRON is suitable for my requirement.
Thanks for the reply. Can i have a code for scheduling the script for every hour ,31 days in a month and 365 days a year? And, CRON is a part of UNIX OS or do we need a buy any special licence for that? Raamc. |
|
||||
|
Quote:
1. add a cron job to check if the script is running, if not start the script. 2. The script should be something like: Code:
#!/bin/sh # Loop forever while : do # Check if cron is running test $(ps ax | grep -c "[c]ron") -gt 0 || /etc/init.d/crond start #Do whatever you have to do echo "Hello world" # Sleep one hour sleep 360 done # Start over |
|
||||
|
You can cron every minute if you need it. crontab entry
Code:
* * * * * [[ -f /path/to/file/filename ]] && mv /path/to/file/filename /path/to/storage/ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|