batch file - Question about bat or maybe schtasks on windows -


i have problem bat or maybe schtasks on windows.

i want backup mysql databases every day automatically, wrote bat file this, call backup.bat:

 @echo off & setlocal enableextensions  set backup_path=d:\backup\ set databases=database1 database2 database3 set username=root set password=123456 set mysql=d:\server\mysql\bin\ set winrar=c:\progra~1\winrar\rar.exe  set year=%date:~0,4% set month=%date:~5,2% set day=%date:~8,2% set minute=%time:~0,2% set second=%time:~3,2%  set dir=%backup_path%%year%\%month%\%day%\ set addon=%year%%month%%day%%minute%%second%  :: create dir if not exist %dir% (     mkdir %dir% 2>nul ) if not exist %dir% (     echo backup path: %dir% not exists, create dir failed.     goto exit )  :: backup echo start dump databases %%d in (%databases%) (     echo dumping database %%d ...     %mysql%mysqldump -u%username% -p%password% %%d > %dir%%%d_%addon%.sql 2>nul     :: winrar     if exist %winrar% (  %winrar% -k -r -s -m1 -ep1 %dir%%%d_%addon%.rar %dir%%%d_%addon%.sql 2>nul  del /f /s /q %dir%%%d_%addon%.sql 2>nul     ) ) echo done  :exit 

i wrote bat file add schtasks, call add.bat:

 @echo off  set file=d:\cron\cron_backup.bat  set frequency=daily  set modifier=1  set datetime=00:30:00  set name="backup cron job"  set user="system"   schtasks /create /ru %user% /sc %frequency% /mo %modifier% /st %datetime% /tn %name% /tr %file% 

then run add.bat, job added system successfully.

it run periodically too. when backup dir, , unrar backup file, file exists, not empty, incomplete. contains few line of should complete backup sqls, backup operation failed.

i tried run backup.bat manually, not use schtasks, works perfectly.

it seems backup operation interrupt something.

so question is: there someting wrote wrong, or missed, or else why schtasks run failed ?


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -