View Full Version : soon.exe experts wanted
Doom9
17th January 2003, 12:25
I'm trying to automate mirroring of certain directories on my HD using robocopy. Towards that end I created the following batchfile called backup.cmd:
robocopy c:\test1 c:\test2 /secfix /mir
soon 300 backup
The first line launches robocopy and does the mirroring, the 2nd one schedules the script to be launched again in 5 minutes.
Now when I execute the script first robocopy runs, then it schedules a new run, but instead of right now plus 5 minutes the task is being scheduled for this time tomorrow plus 5 minutes, so essentially the task is put one day in the future.
The 2nd problem is that when the task is due it doesn't complete.. when I run at it shows tasks in the past as having errors.
TactX
17th January 2003, 20:05
Try renaming 'backup' to 'backup.cmd':
soon 300 backup.cmd
it _should_ work then...
Don't ask me why, it just seems like if 'soon' gets something wrong if you don't add the .cmd :confused:
EDIT: I forgot to mention that your backup.cmd needs to be in c:\winnt or any directory with a path to it. But I highly doubt that the almighty doom would make such a mistake :D
Emp3r0r
17th January 2003, 21:21
I needed to do the the same thing for my job here at the library and make sure some digital photos where backed up to a Snap drive (160 gig network drive). I happened to come accross this interesting program made by some guy at Microsoft and written in C#. It is called FileSync and the full sourcecode is available. I believe if you used it in conjuction with task scheduler it should accomplish what you need to do. If it doesn't just modify the source code. Since you know Java it should be easy!
http://www.gotdotnet.com/Community/User/Samples/download.aspx?FileGuid=f1c37027-d2fa-4517-b0b0-af94143156ce
FileSync is a multithreaded .NET managed WinForm application written in C# that provides a convenient way of doing a full bi-directional synchronization of two directories with handy filtering out of temporary files and conditional selection of subdirectories to be included.
Doom9
17th January 2003, 22:13
@tactX: I also tries with .cmd ending and that didn't work either :(
All required files are in the path so that can't be the problem either.
Also, depending on the integer you set after the soon command the task is being added for today or tomorrow. For instance, if I set the delay to 15 the task is set for tomorrow (15 secs would just give me enough time to delete some files in temp2 so that I can see if robocopy is really doing something), if I use a delay of 300 the task is set for today but to wait 5 minutes to see if something is going to change is really annoying.
Also, when I do it with 5 minutes, after 5 minues there's a new task scheduled for tomorrow at the time the task was supposed to run today, and it's marked as having an error :(
@Emp3r0r: thanks, but I'm looking for something that doesn't require the .net runtime environment. I'm still really sceptical about .net. soon and robocopy are two exe files and would be all that is required to get the job done, it's just that they behave like *nix cli tools (meaning really erratic).
Josephus
29th January 2003, 23:41
Hi Doom ...
I once had the same prob as you and i had an easy solution (alltho it is not 100% the same as you wish to do it.
Norton has in their dos toolkit a little nifty tool that is called
wait.exe or wait.com
You cann call this with a parameter <seconds> so 'wait 300' waits 5 minutes and then the tool exits.
If you create a batch like this :
8<-------------------------------------------
@Echo off
:Loopdeeloop
Robocopy c:\myfart d:\smellsbad
wait 300
goto Loopdeeloop
8<--------------------------------------------
It's a simple tho powerful solution , if you want it to run at approximately every 5 minutes ( if the copyjob takes 2 to 4 minutes simply decrease the wait counter..
You don't have to schedule anything, simply a shortcut to this batchfile in your startup folder oughta do it..
good luck with it ..
If you can't find wait.exe i'll see if i can find it somewhere ...:D
Refthoom
29th January 2003, 23:59
soon 300 "%0"
robocopy c:\test1 c:\test2 /secfix /mir
The soon 300 command schedules the job to run in 300 seconds.
The %0 reschedules the soon command to run again.
I found this with google, so I dunno if this works ;-)
orandennison
30th January 2003, 00:49
Hi Doom9,
another option that would probably do what you want is a program I use to backup all of my important directories every day: a nice little freebie called Taskzip.
http://www.pb-sys.com/
It defaults to creating zipfiles, but you can get it to simply copy the files too without zipping them- which sounds like what you want. I have it set to create sequentially named zipfiles. Every day it deletes the oldest, renumbers them, and adds the latest one. (workbackup1.zip, workbackup2.zip, --> workbackup5.zip being the oldest) You can specify however many backups you want to keep around. This program has saved my butt more than a few times. It's useful for network backups too.
DaveEL
30th January 2003, 02:08
Some programs failto execute .cmd scripts try executing it via cmd.exe
SOON 300 cmd /C C:\path\to\file\backup.CMD
DaveEL
FishB8
30th January 2003, 02:47
Perhaps I might be sticking my head in where it doesn't belong, but I might suggest using a free program called Log Monitor (http://logmon.bitrix.ru/logmon/eng/)
It allows for flexible scheduling and allows you to create custom rules for it to work with. I showed it to a friend of mine who is an administrator for an internet radio station and he found it useful because he could drop a music file into a folder and Log Monitor would detect it, automatically replicate it to the various servers and update each server's data base so that each server knew the new song existed. It was able to take care of some rather complex operations that he was unsuccessfully trying to do with a batch file and saved him lots of time. A big plus is that it can be run as a service in the background.
I have no idea if this can help you at all, but I would recommend at least taking a look at it.
B.R.
FishB8
\AX
30th January 2003, 04:12
::You using linux??
:: well i just read your post again after posting :(...the START /W will wait for a command to finish before carrying on. However it should do that anyhow. Unless...well i never ran that program to comment more on that.
::Im sorry but i have never used either program ever...however if you are trying to do a 5 min delay you could do this. This works on 2k/xp...on nt4/9x you could do a choice.com timeout. Actually the ping trick's work on any win system however you have to create a counter and i think if i remember that is not the easiest...easier to just find a script. However you could do dirty counter with 1's, 2's, 3's set foo=%foo%1 etc..
::Below only works on 2k/xp due to the SET /A
::Ping is ~2 seconds -n determines the number of echos...2 echos is about 1.7 seconds...anyways im not sure if the win98's ping supports -n..if it does this is real easy.
::Also ping supports the -w XXX which means wait for XXX amount of milliseconds between each reply. However i think you need to have a valid(real) IP for that. Anyhow the -n does the same think just in longer intervals.
::This does work on 2k/xp and probably nt4
@echo off
:_start
robocopy c:\test1 c:\test2 /secfix /mir
PING -n 310 127.0.0.1>nul
GOTO _start
::i take that back now i do remember using soon.exe..only after learning serveral ways of doing internal scripts to do the same thing. Advantage of using one of these here or somethign other is that it does not require you to have a non-deployment file.
::Im sorry...again i dont know exactly what your trying to do. Choice and the ../t:Xnn works on nt4/9x i believe. ping works on all of them...below is NT4 WAY to use choice and get the same effect.
:: CHOICE does NOT work on 2k/xp...no longer comes with it. SET /P is it's closest replacement.(which is better to me but has not timeout that i know of)
::IF 98 does not support ping -n (number of echos) then this choice example would work.
::choice can do upto 99 seconds...this will delay for 4:57min's
@echo off
::
:_start
robocopy c:\test1 c:\test2 /secfix /mir
CHOICE /C:N /N /T:N,99
CHOICE /C:N /N /T:N,99
CHOICE /C:N /N /T:N,99
GOTO _start
:: optionally if you dont want to see anything you could do a call, null...like below. The advantage to this is that you dont have to >nul out every command with output. Also some commands like the choice.com do NOT like if you >nul at the end of their very special command :P. Also when scripts get larger it save's bytes.
@echo off
::
IF "%var%"=="1" GOTO _startx
SET var=1
CALL backup.bat>nul
GOTO _EOF
:_startx
set var=
:_start
robocopy c:\test1 c:\test2 /secfix /mir
CHOICE /C:N /N /T:N,99
CHOICE /C:N /N /T:N,99
CHOICE /C:N /N /T:N,99
GOTO _start
:_EOF
::again on linux there is a million and a half tools that can do this...but in win these are to me the less complexed and simplest...
there is many ways to accomplish this same effect with FOR "delims=", TIME/T then FOR. FC.EXE, and several others i know of. Believe it or not the PING delay seems to use less resource's...no clue why though. Seem's it should use more.
bb
30th January 2003, 07:36
Hello Doom9,
I guess this might help you:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q237840
Sincerely
bb
ZoSTeR
30th January 2003, 10:49
If it doesn't have to be robocopy / soon.exe then Second Copy 2000 is a very nice alternative.
http://www.centered.com/products.html
z3r3
30th January 2003, 14:50
i've had similar problems with soon and at commands what I found was that u had enter the time in the last 30 seconds of a minute for it to work. this is because of rounding etc that the stupid scheduler does. i've modified a batch file from experts-echange to take any amount of seconds or minutes and the wait for that time or if u want use the top half of the code to make a time that u can pass to the at command directly (instead of using soon as u may have better luck)
Heres the batch files i've modified for u that i saw on experts exchange:
@echo off
REM To use with at command dont set delays under 60 seconds
REM as M$ is stupid and sometimes set the task for tomorrow
REM ** Delay is set to 1 minutes
set delay_min=0
set delay_sec=300
REM set testtime=%time%
FOR /F "tokens=4 delims== " %%i IN ('NOW') DO SET testtime=%%i
if "%testtime:~0,1%"==" " set testtime=0%testtime:~1%
rem echo Time Now: %testtime:~0,8%
set /A hh=1%testtime:~0,2% - 100
set /A mm=1%testtime:~3,2% + %delay_min% - 100
set /A ss=1%testtime:~6,2% + %delay_sec% - 100
:SECONDS
if /I not %ss% GEQ 60 goto MINUTES
set /A mm=(mm+(ss/60))
set /A ss=ss%%60
:MINUTES
if /I not %mm% GEQ 60 goto NORMALIZE
set /A hh=(hh+(mm/60))%%24
set /A mm=mm%%60
:NORMALIZE
if /I %hh% LSS 10 set hh=0%hh%
if /I %mm% LSS 10 set mm=0%mm%
if /I %ss% LSS 10 set ss=0%ss%
rem echo Scheduled Time: %hh%:%mm%:%ss%
at %hh%:%mm%:%ss% /interactive cmd /c c:\backup.bat
rem at
rem pause
here's a built in delay so u dont need to call at but can execute ur task and then wait for delay to end
@echo off
REM ** Delay is set to 60 seconds
set delay_min=0
set delay_sec=60
REM set testtime=%time%
FOR /F "tokens=4 delims== " %%i IN ('NOW') DO SET testtime=%%i
if "%testtime:~0,1%"==" " set testtime=0%testtime:~1%
echo Start time: %testtime:~0,8%
set /A hh=1%testtime:~0,2% - 100
set /A mm=1%testtime:~3,2% + %delay_min% - 100
set /A ss=1%testtime:~6,2% + %delay_sec% - 100
:SECONDS
if /I not %ss% GEQ 60 goto MINUTES
set /A mm=(mm+(ss/60))
set /A ss=ss%%60
:MINUTES
if /I not %mm% GEQ 60 goto NORMALIZE
set /A hh=(hh+(mm/60))%%24
set /A mm=mm%%60
:NORMALIZE
if /I %hh% LSS 10 set hh=0%hh%
if /I %mm% LSS 10 set mm=0%mm%
if /I %ss% LSS 10 set ss=0%ss%
echo Waiting for: %hh%:%mm%:%ss%
:TIMETEST
REM set testtime=%time%
FOR /F "tokens=4 delims== " %%i IN ('NOW') DO SET testtime=%%i
if "%testtime:~0,1%"==" " set testtime=0%testtime:~1%
if not %testtime:~0,2%==%hh% goto TIMETEST
if not %testtime:~3,2%==%mm% goto TIMETEST
:SECTEST
if /I 1%time:~6,2% LSS 1%ss% goto SECTEST
echo %delay_min% minute(s) and %delay_sec% second(s) has gone by
REM set testtime=%time%
FOR /F "tokens=4 delims== " %%i IN ('NOW') DO SET testtime=%%i
if "%testtime:~0,1%"==" " set testtime=0%testtime:~1%
echo End time: %testtime%
set testtime=
set delay_min=
set delay_sec=
set hh=
set mm=
set ss=
also to see why u have an error try running in interactive mode to see what is going wrong.
dvdWannabe
30th January 2003, 16:08
Use http://search.winnetmag.com/ and put soon in the search box. Lots of good articles on this.
Kaizen
30th January 2003, 18:25
' Mark Saunders ' asked me to post this:
Hi,
I haven't been registered on the board long enuff to reply so I hope
this answer gets to you. Are you using NT4? If so, I know the problem
well. NT4 originally came with the task scheduler run by atsvc.exe. A
version of IE upgraded this to mstask.exe at some stage. Mstask.exe for NT4
is broken. The simple answer for you to get soon.exe working if you are
using NT4 is to stop the task scheduler service and mod it (regedit the
service key) so it runs atsvc.exe again.
Hope this is of some help.
Doom9
30th January 2003, 20:04
@DaveEL: I've already tried that without success.
@bb, kaizen: I'm using xp but I'll try it anyway.
\AX
31st January 2003, 01:46
So what is your problem??? All the above script examples and links to help seem valid and should clear this up. What EXACTLY are you trying to do??
With all the above script examples you dont need soon.exe IF your just trying to create a 5min delay.
Sorry i just dont know exactly what you are trying to do and what is holding you back. This thread seems to be giving you everything you need to accomplish the problem you have presented.
BTW z3r3: Your script will work just fine..only thing i wanted to give you a heads up on was the %time% variable is not always set on ALL systems..or it gets reset. You should use the command to get the time variable. Something like this
FOR /F "tokens=1,2,3,4 delims=PAMpam" %%i IN ('TIME/T') DO SET TIMEX=%%i%%j%%l%%m
you will have to edit it to whatever you got on your system but that way is a sure shot regardless of the %time% being set already to anything. Also something im just ficky about...i use the :: instead of REM as a comment :: is 1 less byte :-)...im just ficky that way.
All in all that is a nice approach.
z3r3
31st January 2003, 08:50
since u r using winxp have thought of using 'schtasks.exe' ('schtasks.exe' replaces 'at' command on winxp) to schedule a task that runs every minute or every 2 minutes or whatever ur need may be.
this way u dont need to run soon but the thing is u may have overlapping tasks doing this if the copy takes 5 minutes and u schedule it to occur every 1 minute!!
Doom9
31st January 2003, 11:32
@ \AX : I didn't claim the tips above didn't work except when I said something to a specific tip by a specific person. I honestly haven't had time to test it all out (it's for my day job and I don't feel like working in the evening so it had to wait till the next possible opportunity - which is now).
I'm trying (now successfully thanks to z3r3's tip) to mirror two directories on two different HDs in a computer at work, and this in a regular interval. Now that I have it working properly on my local computer it's time to try it on the remote machine.
Doom9
1st February 2003, 14:14
@everyone: thanks for your tips, my problem is now solved. schtasks, unlike soon/at always works as advertised so my backup problems are now solved :)
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.