Re: running IDL as a 'sleeping' process [message #78873] |
Wed, 04 January 2012 13:14 |
Russell[1]
Messages: 101 Registered: August 2011
|
Senior Member |
|
|
On Jan 4, 10:21 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jan 3, 5:48 pm, desertdryad <dry...@gmail.com> wrote:
>
>> Is this sort of daily repeating process in the realm of possibility
>> for IDL to do? Should I be thinking of some sort of 'wrapper' program
>> that calls IDL to do this? I know just enough C/C++ to get in
>> trouble :) but not much of anything like Java and the like. Comments
>> and suggestions welcome. Thanks!
>
> One simple and IDL-only (thus platform-independent) way to do it is
> use IDL's wait procedure. The program can do its thing, then call
> systime() to find out how long to sleep, then call wait to sleep for
> the desired time.
This is true, but this will mean you have an IDL prompt sitting there
with no access to it. It will essentially be "stuck" on the wait
statement for a very long time, and you may not want it to start at
some preset time. Instead, a (perhaps more elegant) way along these
lines, would be to use the widget_timer functionality. What amounts
to the wait command with a long wait time derived from systime() would
then be enveloped in an event handler that would trigger at some
defined time. That could be simple (such as every 24 hours trigger),
or you could test the existence of some auxiliary file (say every 30s
or so) and when the file exists, then trigger the main code. This is
probably a lot more work than you signed up for, but really not that
bad once you get the hang of it. The virtue of this is that you get
the IDL prompt back, and this thing essentially runs "in the
background".
Russell
|
|
|
Re: running IDL as a 'sleeping' process [message #78880 is a reply to message #78873] |
Wed, 04 January 2012 07:21  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jan 3, 5:48 pm, desertdryad <dry...@gmail.com> wrote:
> Is this sort of daily repeating process in the realm of possibility
> for IDL to do? Should I be thinking of some sort of 'wrapper' program
> that calls IDL to do this? I know just enough C/C++ to get in
> trouble :) but not much of anything like Java and the like. Comments
> and suggestions welcome. Thanks!
One simple and IDL-only (thus platform-independent) way to do it is
use IDL's wait procedure. The program can do its thing, then call
systime() to find out how long to sleep, then call wait to sleep for
the desired time.
|
|
|
Re: running IDL as a 'sleeping' process [message #78885 is a reply to message #78880] |
Tue, 03 January 2012 14:20  |
Vincent Sarago
Messages: 34 Registered: September 2011
|
Member |
|
|
As bstecklu said, the best way to do a scheduling task is to combine a cron (unix) + a script calling the IDL procedure
here is an example of script :
#!/bin/sh
#set -x
#Working Directory
DIR=~/
# IDL directory
IDL="/opt/idl8/idl/bin/idl80"
LOCK=$DIR/.tasklock
# Function to delete the lock file
clean() {
rm -f ${lock}
}
# cette fonction verifie si les 5 fichiers sont arrivé et lance IDL
dowork () {
FILE=$1
#Start IDL and run program
$IDL -32 -quiet -queue 2>> $DIR/log.txt <<here
restore, '../../directory/project.sav'
spawn, 'echo $file', input
procedure, input
exit
here
}
#when end of script, call clean()
trap clean 0
# if lock found ...
if [ -f ${lock} ]; then
# ... if process is still running ...
if [ -d /proc/`cat ${lock}` ]; then
exit 0
fi
fi
# writing process number in the lock file
echo -n $$ > "$lock"
FIND=$(find $DIR -maxdepth 1 -name 'file.tmp')
echo "$FIND" | while read file; do
[ -z "$file" ] && continue
dowork $input
done
# delete lock file
clean
vincent
|
|
|
Re: running IDL as a 'sleeping' process [message #78886 is a reply to message #78885] |
Tue, 03 January 2012 13:04  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Under Linux you can use crontab to call a script that runs your code.
Your script could be something like:
#!/bin/bash
cd /idl_routine_path
idl -e your_routine
Under Windows you could use scheduled tasks to do something similar
but you have to create a SAV file.
Your 3th option is run the code in background. Using the command WAIT
you can do what you want. I combine this technique with the first one
to run some of my "invisible" IDL scripts to download and process data
every X time.
nata
|
|
|
Re: running IDL as a 'sleeping' process [message #78888 is a reply to message #78886] |
Tue, 03 January 2012 12:59  |
Bringfried Stecklum
Messages: 75 Registered: January 1996
|
Member |
|
|
If the code shall run at regular times I recommend to use a shell script as a
wrapper in combination with cron for the scheduling. At least for Linux this is
fairly easy to do. There is no need to keep the IDL process forever in memory.
Regards, Bringfried
desertdryad wrote:
> Hi folks -
>
> This is a bit of an ignorant newbie question. I am developing a
> fairly complex bit of code, that in the long run will ideally entail
> daily data retrieval from the web, parsing that data and making
> several calculations, spitting out results, and then going to 'sleep'
> until the following day, when it all repeats. I'm wondering if this
> is even something IDl can *do*. I'm sure there are better platforms
> to develop such a sort of program, but I'm hoping not to reinvent the
> wheel on the development I've done so far (I've built several modules
> already in IDL for this project). I'm currently worknig under
> Windows, but it's highly likely this project will be migrating to a
> Linux OS.
>
> Is this sort of daily repeating process in the realm of possibility
> for IDL to do? Should I be thinking of some sort of 'wrapper' program
> that calls IDL to do this? I know just enough C/C++ to get in
> trouble :) but not much of anything like Java and the like. Comments
> and suggestions welcome. Thanks!
|
|
|