The script does not create files.
I figure out that the task is running but my script is not running automatic/manual 12:00 AM to 9:59 AM however once clock set 10:00 AM the script ran.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Experts,
I have a backup script which I wanted to run DAILY every 3 hours but it's not working whats I am doing there.
The script did not run in between 11:00 PM to 11:00 AM.
The script does not create files.
I figure out that the task is running but my script is not running automatic/manual 12:00 AM to 9:59 AM however once clock set 10:00 AM the script ran.
once clock set 10:00 AM the script ran.
That's because you now have a 2 digit hour (one zero at 10AM) instead of single digit hour (space nine at 9AM).
When you run a command line program, a space separates the arguments that are passed to the program.
dir C:\Program Files
dir "C:\Program Files"
In the first line the dir command will see 2 arguments, C:\Program and Files. There is no C:\Program folder so it returns a file not found. Normally a program would also generate an error indicating that Files is not a valid argument.
You have to put quotes around the folder name so that it is treated as the first argument. Because the name contains a space.
Did you put the quotes around the file names as I showed you? Prior to 10AM, your file names will contain a space. If you don't put quotes around them, then the expdp program will see the part of the file name that comes after the space and think that is is another parameter that it needs to process. But is it not a valid argument. It is generating an error, but you don't see that because you are not capturing stdout and stderr (the output that normally is displayed in a command prompt window).
Do you understand what I am tying to explain to you? Manually run that expdp command from a command prompt before 10AM and you will see the error.
Update: Here is how to capture stdout and stderr.
Create 2 folders:
C:\Scripts
C:\Scripts\Logs
Use notepad and create a file named C:\Scripts\Export2.bat with this content.
@echo ============================================================
@echo %date% - %time% Export2 script is starting.
REM Set the current drive and directory here. I have no way of knowing what your requirements are.
REM Here is an example.
D:
cd d:\Data\MyBackupFolder
REM End of example
REM Now run the export
expdp wbg/chl@chl full=Y directory=dbbackup dumpfile="CHL_%date:~4,2%_%date:~7,2%_%date:~10,4%-%time:~0,2%%time:~3,2%.dmp" logfile="CHL_%date:~4,2%_%date:~7,2%_%date:~10,4%-%time:~0,2%%time:~3,2%.log"
@echo %date% - %time% Expdp RC=%errorlevel%
@echo %date% - %time% Export2 script is ending.
Change the scheduled task to execute program "cmd.exe".
In the arguments field set it to:
/c C:\Scripts\Export2.bat 1>>"C:\Scripts\Logs\Export2-%date:~10,4%-%date:~4,2%%date:~7,2%.log" 2>&1
That will create a daily log file of all executions of the task. (Assuming that the date time format on your PC matches mine.)