Run Periodic Tasks

Run Periodic Tasks with vovliveness

If the directory "tasks" exist in the Server Working Directory, the server calls the vovliveness script once per minute.

The script executes all the tasks contained in the "tasks" directory.


vovliveness: Usage Message
  
  DESCRIPTION:
      This script is called by vovserver about once a minute.
      It can be used to perform maintenance tasks.
  
  USAGE:
      % vovliveness [OPTIONS] <taskdirectory> <timestamp>
  
  WHERE:
     task_directory     -- is the directory with the tasks
                           to be executed. The tasks are those
                           that match the expression "live_*.tcl".
     timestamp          -- Currently ignored.
  
  OPTIONS:
     -v                 -- Increase verbosity.
  

There are many uses for vovliveness. Examples are available in the directory $VOVDIR/etc/liveness.

To activate this functionality, create the directory tasks and add some tasks files with a name matching the expression live_*.tcl. The Tcl interpreter has access to all vtk_* procedures. Example:
% cd `vovserverdir -p .`
% mkdir tasks
% cd tasks
% cp $VOVDIR/etc/liveness/live_start_taskers.tcl .
Following an example of the script live_start_taskers.tcl to restart any down taskers, once per hour:
#
# Copyright © 2007-2021, Altair Engineering
#
# All Rights Reserved.
#
# Directory : src/scripts/liveness
# File      : live_start_taskers.tcl
# Content   : Start down taskers once an hour.
# Note      :
#
# $Id: //vov/branches/2019.01/src/scripts/liveness/live_start_taskers.tcl#3 $
#

set now [clock seconds]

# Get or initialize period
if { [catch {set period [vtk_prop_get 1 LIVE_START_TASKERS_PERIOD]}] } {
    set period 3600
    catch {vtk_prop_set 1 LIVE_START_TASKERS_PERIOD $period}
}

# Get age
if { [catch {set lastRun [vtk_prop_get 1 LIVE_START_TASKERS_LAST]}] } {
    set lastRun 0
}
set age [expr {$now - $lastRun}]

if { $age >= $period } {

    # Start down taskers
    if { [catch {exec vovtaskermgr start >&@ stdout} errmsg] } {
        VovError "Failed to start taskers: $errmsg"
    }

    # Reset the last run TS
    catch {vtk_prop_set 1 LIVE_START_TASKERS_LAST $now}

}

Alerts from Liveness Tasks

Alerts may occur that are related to liveness tasks such as "The previous liveness script is still connected", especially in Monitor.
Note: In previous releases, there is no control these occurrences; such occurrences cause no harm.

The liveness tasks system is designed to support short jobs that are triggered frequently (about once per minute) by the vovserver so long as it is running. It was also used for the database loading task for Monitor checkouts and Accelerator jobs; sometimes these jobs run significantly longer.

In later releases the debuglog parsing, batch reports and other maintenance items are converted to periodic jobs that run on a dedicated vovtasker named 'maintainer', so these alerts should no longer appear.

Run Periodic Tasks with vovcrontab

The UNIX utility crontab is used to perform regularly scheduled tasks such as retracing an entire project each night or storing a back-up of the trace every Saturday. vovcrontab is a VOV utility that simplifies the creation of cron rules for a project. Directions are provided in this section.

Usage: voncontrab

vovcrontab: DESCRIPTION:
vovcrontab:     Interface to the UNIX utility crontab.
vovcrontab: 
vovcrontab: USAGE:
vovcrontab:     % vovcrontab [option]
vovcrontab: 
vovcrontab: OPTIONS:
vovcrontab:   -help        -- Get this message
vovcrontab:   -new         -- Install the crontab for this project
vovcrontab:                   Also used to update the scripts/vovdir.csh script.
vovcrontab:   -noautostart -- Do not install autostart script to update
vovcrontab:                   vovdir.csh; the default is to install it.
vovcrontab:   -reinstall   -- Reinstall current crontab for this project
vovcrontab:   -clear       -- Clear the current crontab
vovcrontab:   -show        -- Show the crontab
vovcrontab:   -type <type> -- Specify project type
vovcrontab: 
vovcrontab: NOTE:
vovcrontab:     Please remember to copy
vovcrontab:     $(VOVDIR)/etc/autostart/update_crontab_vovdir.csh
vovcrontab:     into your autostart directory if needed.
vovcrontab:     It is installed by default.

Enable a Project

Enable a project in a shell via:
'vovproject enable <PROJECT>'

Create crontabs

Execute 'vovcrontab -new' to create crontabs.
% vovcrontab -new
vovcrontab: Creating vnc.swd/scripts/cron.csh
vovcrontab: Creating cron table vnc.swd/crontab.lion
no crontab for john
vovcrontab: Installing new crontab.
vovcrontab: Installing updated crontab

This program prepares the scripts $SWD/scripts/cron.csh and $SWD/crontab.hostname.

Display Current crontab Definition

Running vovcrontab -show shows the current crontab definition.
% vovcrontab -show
#### (vovcrontab) START PROJECT vnc ####
#
# ... some lines omitted...
#
# Every hour at 5 minutes before the hour.
55 * * * *  /home/john/vov/vnc.swd/scripts/cron.csh hourly
#
# Every day: at 23:15
15 23 * * *     /home/john/vov/vnc.swd/scripts/cron.csh daily
# 
# Every week: on Saturday at 7:00am
0  7  * * 6     /home/john/vov/vnc.swd/scripts/cron.csh weekly
#
# Every month: on the 1st at 3:00am
0  3  1 * *     /home/john/vov/vnc.swd/scripts/cron.csh monthly
#### (vovcrontab) END PROJECT vnc ####

Customize the crontab

The crontab can be customized by editing either $SWD/crontab.hostname or $SWD/scripts/cron.csh. Afterwards, vovcrontab -reinstall will need to be run to take the modifications into consideration.
% vovcrontab -reinstall
vovcrontab: vnc.swd/scripts/cron.csh  exists already.
vovcrontab: vnc.swd/crontab.lion exists already.
vovcrontab: Installing new crontab.
vovcrontab: Installing updated crontab

Delete the Current crontab Definition

To delete current crontab definitions, use:
'vovcrontab -clear'
vovcrontab: vnc.swd/scripts/cron.csh  exists already.
vovcrontab: vnc.swd/crontab.lion exists already.
vovcrontab: Removing the crontab

Complete the Cleanup

To complete the cleanup, remove the crontab.HOSTNAME file in the SWD directory of the project.
% rm crontab.lion