[wpkg-users] Running wpkg.js as System Account
Troy Hamilton
troy.a.hamilton at gmail.com
Fri Jan 7 18:24:11 CET 2011
2011/1/7 LAPLAUD François <laplaud at sdis72.fr>
> Yes indeed,
>
> Here are my needs :
> - a working wpkg ( ;-) )
> - possibility to run wpkg periodically to be able to deploy packages in
> background while users are working.
>
I use CRON (http://www.kalab.com/freeware/cron/cron.htm) to do this. I
prefer these native versions to PyCron since they don't require a Python
installation.
For running WPKG, I use the crons.exe version which installs itself as a
service. After copying crons.exe and a crontab file to C:\WINDOWS\SYSTEM32,
I just run these two commands:
c:\windows\system32\crons.exe /install
c:\windows\system32\sc.exe start CRON
And here is an example of the crontab that I use (look out for wrapped lines
below):
-----------------------------------------------------
# Basic crontab format:
#
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0)
# | | | | |
# * * * * * command to be executed
# refresh the crontab file every 10 minutes
0,10,20,30,40,50 * * * * c:\windows\system32\xcopy.exe /y
"\\myserver\myshare\APPS\cron\crontab" "c:\windows\system32"
# run wpkg.bat at 10pm, midnight, and 2am each day
0 22,0,2 * * * c:\windows\system32\cmd.exe /c \\myserver\myshare\APPS
\wpkg\wpkg.bat
-----------------------------------------------------
Now this takes care of the scheduled after hours synchronization. And for
ad-hoc installations during business hours, I can just add another line to
the crontab file to run wpkg for installing a particular package:
#55 9 * * * cmd.exe /c \\myserver\myshare\apps\wpkg\wpkg.bat urgent-package
All of my workstations will pull down the new copy of the crontab file
within 10 minutes, and then they will run wpkg at 9:55 AM in this case to
install "urgent-package". After that time has passed, I can remove the line
from the crontab file so that it doesn't run everyday after that.
Of course, I also use beyondexe or psexec sometimes if I just have a few
workstations to work with.
By the way, I like CRON better than scheduled tasks because it's much easier
to copy out a new crontab file than to modify the scheduled task(s). I also
remember having some issues with the scheduled tasks not running reliably.
If I need to use scheduled tasks, why would I run a service wich will in
> return run a script whereas I can run that script directly ?
At one point I installed a "custom" wpkg service, but I abandoned that when
I implemented cron. The only advantage of the service is that I used
setacl.exe to modify the permissions of the service so that limited users
could start and stop it.
- when the scheduled tasked is about to run wpkg, I would like it to wait
> for some random time between 1 and 30 minutes for instance so that the
> network is not overloaded. (I suppose this part will need little
> modifications of the wpkg.js script itself but seems to be a quite easy one)
>
I've thought of that before, too, and I think I may modify my wpkg.bat file
as follows (note the "set /a delay" line:
wpkg.bat
*---------------------------------------------------------*
@echo off
set WPKGROOT=%~dp0
CALL "%~dp0setServer.bat"
set SOFTWARE=\\%SERVER%\software
IF NOT EXIST %SOFTWARE% EXIT /B 1
c:\windows\system32\msiexec.exe /unreg
c:\windows\system32\msiexec.exe /regserver
IF EXIST c:\windows\system32\wpkg.xml DEL /Q /F c:\windows\system32\wpkg.xml
set
PATH=c:\windows;c:\windows\system32;c:\windows\system32\wbem;%WPKGROOT%\tools;%PATH%
:: random number of seconds between 1 and 1800 (30 minutes)
set /a delay=%random%%1800+1
:: sleep.exe from gnuwin32
%WPKGROOT%\tools\sleep.exe %delay%
IF [%1]==[] (
c:\windows\system32\cscript.exe //nologo /E:JScript %WPKGROOT%\wpkg.js
/synchronize /noremove /quiet /nonotify /sendStatus /logLevel:23
/log_file_path:\\myserver\work\log\wpkg
/logfilePattern:[HOSTNAME]-[YYYY][MM][DD]-[hh][mm].log
) ELSE (
IF [%2]==[force] (
c:\windows\system32\cscript.exe //nologo /E:JScript
%WPKGROOT%\wpkg.js /forceinstall /install:%1 /noremove /quiet /nonotify
/sendStatus /logLevel:23 /log_file_path:\\myserver\work\log\wpkg
/logfilePattern:[HOSTNAME]-[YYYY][MM][DD]-[hh][mm].log
) ELSE (
c:\windows\system32\cscript.exe //nologo /E:JScript
%WPKGROOT%\wpkg.js /install:%1 /noremove /quiet /nonotify /sendStatus
/logLevel:23 /log_file_path:\\myserver\work\log\wpkg
/logfilePattern:[HOSTNAME]-[YYYY][MM][DD]-[hh][mm].log
)
)
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%
set tm=%time:~0,8%
set tm=%tm::=-%
set tm=%tm: =%
IF EXIST c:\windows\system32\wpkg.xml RENAME c:\windows\system32\wpkg.xml
wpkg-%year%-%month%-%day%-%tm%.xml
---------------------------------------------------------
Hope this helps,
Troy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20110107/aa2cfc26/attachment-0002.html>
More information about the wpkg-users
mailing list