//============================================================================= // // Task: SYNCMODF.TSK // (Triggers synchronization based upon detection of file changes) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - Initial Release // (08 May 2002) // // Description: // ============ // Monitor one or more files in real-time (check every second) and initiate // a SYNC upon detection of completed file change/update. // // Objective: // ========== // Maintain as close to real-time of a synchronization as possible. // // Usage: // ====== // Script can be manually executed using the TaskMaster TMRUN command // at the TMConsole (Shell) Screen: // // Example: TMRUN [vol:path\]SYNCMODF.TSK // // Note: [vol:path\] is not required if the task resides either // in SYS:SYSTEM or the TaskMaster NLM load directory. // // Script can be scheduled for automatic execution using Client interface or // using the TaskMaster TMSCHEDULE command at the TMConsole (Shell) Screen: // // Examples: TMSCHEDULE ADD SYNCMODF.TSK 01 02:00 // (Executes the 1st of each month at 2:00am) // // TMSCHEDULE ADD SYNCMODF.TSK YNNNNNN 02:00 // (Executes every Sunday [SMTWTFS] at 2:00am) // // Note: Scheduled tasks must reside either in SYS:SYSTEM or the // TaskMaster NLM load directory for security reasons. // // Once executed, the task runs continuously until the Server is downed, the // TaskMaster NLM is unloaded, or the task is aborted. Logic at the start of // the task checks to make sure that only one instance of the task is running. // // Compatibility: // ============== // This task has been tested on the following platforms without demonstrating // any compatibility issues or any other reported/confirmed conflicts: // TaskMaster v4.04 (or later) // NetWare v3.12 / v3.2 / v4.1x / v4.2 / v5.x / v6.x // // Warning: // ======== // AS WITH ANY NEW SOFTWARE PROGRAM, BATCH SCRIPT, OR AUTOMATED PROCESSING // PROCEDURE, CAUTION SHOULD BE EXERCISED AND DUE DILIGENCE OBSERVED DURING // INITIAL IMPLEMENTATION. WHERE POSSIBLE, TESTING SHOULD BE PERFORMED ON // NON-PRODUCTION SYSTEMS PRIOR TO FULL IMPLEMENTATION. // // Comments: // ========= // This task script is provided free of charge and without any warranty or // guarantee of fitness of purpose or performance. // // For additional TaskMaster script examples, visit the Sample Tasks page // on the Avanti Technology, Inc. WEB Site: http://www.avanti-tech.com // //============================================================================= // Check that the version of TaskMaster loaded is compatible (4.04 or later) IF "%TM_VERSION%.%TM_SUBVERSION%%TM_REVISION%"<"4.04" // Echo the problem message to the screen ECHO. ECHO Error: Incompatible TaskMaster release (requires v4.04 or later)! ECHO. ABORT ENDIF // Check that no other instances of this task are running (Limit: 1 instance) IF ACTIVE_TASK %TASK% // Echo the problem message to the screen ECHO. ECHO Error: %TASK% is already running! ECHO. ABORT ENDIF // Label designating a section of logic or GOTO jump point :START // Define the name of the file which will trigger a SYNC once updated (%0) // then get the initial Last Modified date/time stamp (%1) with first pass. // // This example checks for updates to SYS:\SYSTEM\SYS$LOG.ERR to trigger SYNC. // When changing the example for specific use, replace SYS:\SYSTEM\SYS$LOG.ERR // with a valid file name to be monitored. DEFINE %0 SYS:\SYSTEM\SYS$LOG.ERR // Label designating a section of logic or GOTO jump point :MONITOR // The current Last Modified date/time stamp for the monitored file (%0) DEFINE %1 %FILE_UPDATE_%0% // The WHILE/LOOP that actually does the monitoring // Stays in the WHILE/LOOP as long as the Last Modified date/time for the file // remains unchanged or the file is in use (i.e., still open so can't SYNC). // Once modified and no longer open, WHILE/LOOP breaks and SYNC (below) starts. WHILE %1==%FILE_UPDATE_%0% OR FILE_IN_USE %0 // Suspend processing (SLEEP) for a second then check again SLEEP 1 LOOP // Monitored file changed and no longer in use so launch the appropriate SYNC. // // The SYNC action and output is redirected to a log which can be reviewed // and will periodically need to be cleared since it continuously appends. // Define the SYNC output log file (check this log for errors after processing) // Notes: SYNC log file name is same as .TSK file name but with .LOG extension. // DEFINE technique is used to simplify subsequent referencing via %9. DEFINE %9 %TASK_PATH%\%TASK_FILE%.LOG // OPEN the log file for task WRITE output (append mode) OPEN_WRITE %9 // Record the start of this SYNC WRITE SYNC update: %MONTH%/%DAY% at %HOUR%:%MINUTE%:%SECOND%%AM_PM% // CLOSE the log file so it can be used for SYNC output redirection CLOSE // This example SYNCs the SYS:SYSTEM directory to a Remote Failover Server. // // /A (Add) - add new source file(s) to destination // /D (Delete) - delete any destination file(s) not on source // /L (Log) - write the command line and options to redirection output file // /M (Modify) - modified source files copied to destination // /# (Stats) - Include processing statistics in final summary // >>%9 - redirect the console output to the %9 defined file (i.e., log) // // Note: Change source vol:path and destination server/vol:path to customize. SYNC SYS:\SYSTEM R_SERVER/SYS:\SYSTEM /a /d /l /m /# >>%9 GOTO MONITOR