script which does not work via AT command

A

--== Alain ==--

Hi,

i have a little issue with a command script run via AT command.
if i run it manually, it works perfectly. so where is the problem ?

start_backup.cmd is run via AT 20:00 /EVERY:m,t,w,th,f start_backup.cmd
all scripts are run except that the moving from C to P drive does not
work and i do not know why.

Could you help me please ?
thanks,

Alain.


start_backup.cmd :
----------------
@echo OFF
call C:\srv_al\backup.cmd >> C:\srv_al\backup.log
call C:\srv_al\moving.cmd >> C:\srv_al\backup.log

-------------------------------------------

backup.cmd :
----------
@ECHO OFF
echo Backup PHP folder... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\PHP5_bak.zip C:\PHP\*.*
echo Backup PHP folder... END
echo.
echo Stop APACHE server...
apache.exe -w -n "Apache2" -k stop
echo.
echo Backup APACHE folder... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\apache2_bak.zip "c:\Program
Files\Apache Group\Apache2\*.*"
echo Backup APACHE folder... END
echo.
echo Start APACHE server...
apache.exe -w -n "Apache2" -k start
echo.
echo Stop PostGreSQL database service...
net.exe stop pgsql-8.1
echo.
echo Backup POSTGRESQL database... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\psql_bak.zip
c:\progra~1\postgr~1\*.*
echo Backup POSTGRESQL database... END
echo.
echo Start PostGreSQL database service...
net.exe start pgsql-8.1

and the last one, moving.cmd :
----------------------------
echo @OFF
echo.
C:\
cd\srv_al
echo Moving backup files to P drive
move /Y "C:\srv_al\*.zip" "P:\my documents\tools\kmt"
 
P

Pegasus \(MVP\)

--== Alain ==-- said:
Hi,

i have a little issue with a command script run via AT command.
if i run it manually, it works perfectly. so where is the problem ?

start_backup.cmd is run via AT 20:00 /EVERY:m,t,w,th,f start_backup.cmd
all scripts are run except that the moving from C to P drive does not
work and i do not know why.

Could you help me please ?
thanks,

Alain.


start_backup.cmd :
----------------
@echo OFF
call C:\srv_al\backup.cmd >> C:\srv_al\backup.log
call C:\srv_al\moving.cmd >> C:\srv_al\backup.log

-------------------------------------------

backup.cmd :
----------
@ECHO OFF
echo Backup PHP folder... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\PHP5_bak.zip C:\PHP\*.*
echo Backup PHP folder... END
echo.
echo Stop APACHE server...
apache.exe -w -n "Apache2" -k stop
echo.
echo Backup APACHE folder... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\apache2_bak.zip "c:\Program
Files\Apache Group\Apache2\*.*"
echo Backup APACHE folder... END
echo.
echo Start APACHE server...
apache.exe -w -n "Apache2" -k start
echo.
echo Stop PostGreSQL database service...
net.exe stop pgsql-8.1
echo.
echo Backup POSTGRESQL database... START
wzzip -a -ee -Jhrs -P -r -ybc C:\Srv_Al\psql_bak.zip
c:\progra~1\postgr~1\*.*
echo Backup POSTGRESQL database... END
echo.
echo Start PostGreSQL database service...
net.exe start pgsql-8.1

and the last one, moving.cmd :
----------------------------
echo @OFF
echo.
C:\
cd\srv_al
echo Moving backup files to P drive
move /Y "C:\srv_al\*.zip" "P:\my documents\tools\kmt"

There are a couple of basic issues with your script:
- You have numerous references to executables that
are not fully referenced. I suspect that the batch file
is quite unable to locate files such as "apache.exe"
or "wzzip.exe". Make it a habit of fully referencing
all non-windows programs!
- Drive P: may exist in your foreground session but
it is unlikely to exist under the scheduled task. Use
UNC coding rather than drive letters and make sure
that the account you use for the scheduled job has
sufficient access rights to the mapped resource.
 
A

--== Alain ==--

There are a couple of basic issues with your script:
- You have numerous references to executables that
are not fully referenced. I suspect that the batch file
is quite unable to locate files such as "apache.exe"
or "wzzip.exe". Make it a habit of fully referencing
all non-windows programs!
for that there is a set Path at the beginning of the script that i did
not write in the previous post...but it setup everything and as i wrote
before, if i run manually start_backup.cmd (double click on it)... the
scripts work well. (as expected)
- Drive P: may exist in your foreground session but
it is unlikely to exist under the scheduled task. Use
UNC coding rather than drive letters and make sure
that the account you use for the scheduled job has
sufficient access rights to the mapped resource.


account and mapped disk are accessible or well setup....
this is my problem :-(

everything looks well done.
any other idea ?

Alain
 
P

Pegasus \(MVP\)

--== Alain ==-- said:
for that there is a set Path at the beginning of the script that i did
not write in the previous post...but it setup everything and as i wrote
before, if i run manually start_backup.cmd (double click on it)... the
scripts work well. (as expected)



account and mapped disk are accessible or well setup....
this is my problem :-(

everything looks well done.
any other idea ?

Alain

Modify your master batch file like so:
@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
dir "P:\my documents\tools\kmt" 1>>c:\test.log 2>>&1
call C:\srv_al\backup.cmd 1>>c:\test.log 2>>&1
call C:\srv_al\moving.cmd 1>>c:\test.log 2>>&1

Remove the "@echo off" statements in the two batch
files you call, then run the batch file first in the foreground,
then as a scheduled job, testing c:\test.log after each run.
 
A

--== Alain ==--

Modify your master batch file like so:
@echo off
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
dir "P:\my documents\tools\kmt" 1>>c:\test.log 2>>&1
call C:\srv_al\backup.cmd 1>>c:\test.log 2>>&1
call C:\srv_al\moving.cmd 1>>c:\test.log 2>>&1

Remove the "@echo off" statements in the two batch
files you call, then run the batch file first in the foreground,
then as a scheduled job, testing c:\test.log after each run.

it works well with these changes :)
thx.

Alain
 
A

--== Alain ==--

What is the purpose of 1 and 2 ?
and what does it mean &1 ?

thanks a lot,

Alain
 
P

Pegasus \(MVP\)

1>c:\test.txt will direct standard output to c:\test.txt.
2>c:\test.txt will direct error output to c:\test.txt.
2>&1 will direct error output to the same stream as standard output.
 
P

Pegasus \(MVP\)

I just realised that you're running your script with at.exe.
Scripts that use this command use the System account,
which has no access to networked resources. Use the
Task Scheduler or else schtasks.exe.
 
Top