Personal tools

Difference between revisions of "Run scripts more than once per minute"

From PhotoVoltaic Logger new generation

Jump to: navigation, search
(Created page with "Category:ScriptsCategory:HowTo If you run the scripts by cron, the most often frequency is once per minute. PVLng offers a wrapper script <tt>PVLng-run.sh</tt> to ru...")
 
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Scripts]][[Category:HowTo]]
 
[[Category:Scripts]][[Category:HowTo]]
 
 
If you run the scripts by cron, the most often frequency is once per minute.
 
If you run the scripts by cron, the most often frequency is once per minute.
  
PVLng offers a wrapper script <tt>PVLng-run.sh</tt> to run a script more than once per minute.
+
PVLng offers a wrapper script <tt>PVLng-run.sh</tt> to run commands or other scripts more than once per minute.
  
 
  # ./PVLng-run.sh -h
 
  # ./PVLng-run.sh -h
 
   
 
   
  Run command each period seconds for 1 minute.
+
  Run command each given period (in seconds) for 1 minute.
  Use in cron with cron period * for each minute.
+
  Use in cron with period * for each minute.
 
   
 
   
  Usage: PVLng-run.sh [options] -- command parameter1 parameter2 ...
+
  usage: ./PVLng-run1.sh [options] -- script arg1 arg2 ...
 
   
 
   
  Options:
+
  options:
     -p   Period in seconds, default: 60 (run once)
+
     -p, --period            Run each ? seconds for 1 minute (runs by default once) [default:60]
     -t   Test mode
+
    -n, --nice              Niceness range from -20 (most favorable) to 19 (least favorable) [default:10]
    -v    Set verbosity level to info level
+
     -t, --test              Test mode, set verbosity to info level [flag]
     -vv  Set verbosity level to debug level
+
     -v, --verbose            Verbosity, use multiple times for higher level [flag]
     -h   Show this help
+
     -h, --help              This usage help
 +
 +
Don't miss the -- !
 +
 
 +
'''Don't forget to divide the real script name and its parameters with the "<tt>--</tt>"'''
  
 
I monitor my power consumption and my SMA inverters with the following cron tab entries:
 
I monitor my power consumption and my SMA inverters with the following cron tab entries:
Line 28: Line 31:
 
  *      *    *  *  *  ~/PVLng-run.sh -p 15 -- ~/S0/S0.sh -s Consumption.conf
 
  *      *    *  *  *  ~/PVLng-run.sh -p 15 -- ~/S0/S0.sh -s Consumption.conf
  
Don't forget to divide the real script name and its parameters with the "<tt>--</tt>"
+
If you run the wrapper script in verbose test mode, it will show you only what will happen:
 +
 
 +
#  ~/PVLng-run.sh -tvp 30 -- ~/SMA/Webbox.sh -s Inverters.conf
 +
[19:58:02.550] Period : 30
 +
[19:58:02.554] Command: ~/PVLng-scripts/SMA/Webbox.sh -s Inverters.conf
 +
[19:58:02.559] Run, 1 left ...
 +
[19:58:02.563] Test mode ...
 +
[19:58:32.572] Run, 0 left ...
 +
[19:58:32.576] Test mode ...
 +
 
 +
For more accuracy the wrapper script will spawn the concrete command into background, so it have not to wait for it.

Latest revision as of 16:40, 28 September 2014

If you run the scripts by cron, the most often frequency is once per minute.

PVLng offers a wrapper script PVLng-run.sh to run commands or other scripts more than once per minute.

# ./PVLng-run.sh -h

Run command each given period (in seconds) for 1 minute.
Use in cron with period * for each minute.

usage: ./PVLng-run1.sh [options] -- script arg1 arg2 ...

options:
    -p, --period             Run each ? seconds for 1 minute (runs by default once) [default:60]
    -n, --nice               Niceness range from -20 (most favorable) to 19 (least favorable) [default:10]
    -t, --test               Test mode, set verbosity to info level [flag]
    -v, --verbose            Verbosity, use multiple times for higher level [flag]
    -h, --help               This usage help

Don't miss the -- !

Don't forget to divide the real script name and its parameters with the "--"

I monitor my power consumption and my SMA inverters with the following cron tab entries:

# Fetch plant data each 30s, run mostly during daylight times mostly
*    4-22    *   *   *   ~/PVLng-run.sh -p 30 -- ~/SMA/Webbox.sh -s Inverters.conf
*    4-22    *   *   *   ~/PVLng-run.sh -p 30 -- ~/SMA/Webbox.sh -s Sensorbox.conf

# Fetch consumption data each 15s 
*       *    *   *   *   ~/PVLng-run.sh -p 15 -- ~/S0/S0.sh -s Consumption.conf

If you run the wrapper script in verbose test mode, it will show you only what will happen:

#  ~/PVLng-run.sh -tvp 30 -- ~/SMA/Webbox.sh -s Inverters.conf
[19:58:02.550] Period : 30
[19:58:02.554] Command: ~/PVLng-scripts/SMA/Webbox.sh -s Inverters.conf
[19:58:02.559] Run, 1 left ...
[19:58:02.563] Test mode ...
[19:58:32.572] Run, 0 left ...
[19:58:32.576] Test mode ...

For more accuracy the wrapper script will spawn the concrete command into background, so it have not to wait for it.