Jump to content

scheduled task woes


Recommended Posts

Guest Thomas R. Hart II
Posted

Hello everybody. I'm having an issue with scheduled tasks that I can't

seem to put my finger on. I have a task set up (I've set this up both

through the gui and the command line btw, just to test) that runs a file

C:\pg_backup.bat (right now the file is blank, no commands), with a

working directory of C:\. I've tried fixing some of the common pitfalls

(not running it from a mapped drive, make sure the runas user has logon

as a batch job rights in local security settings) yet every time I try

to run this job (right clicking on it and selecting run) it fails and

returns an error code of 0x01 (according to a microsoft support article

(http://support.microsoft.com/kb/308558), the code translates to "0x1:

An incorrect function was called or an unknown function was called."

which is extrememly helpful to me </sarcasm>). I've tried anything I can

find (including setting it up and testing at the server terminal itself)

without success.

 

This is the latest entry in the scheduled tasks log

 

"Database Backup.job" (pg_backup.bat)

Finished 11/15/2007 2:01:54 PM

Result: The task completed with an exit code of (1).

 

Is there anybody out there that has any ideas, or something it seems

like I didn't try yet? This task is a backup for our postgresql database

that's pretty critical. We do have other scheduled tasks running

properly on this machine as well. At this point I'm pretty stuck.

 

TIA for any assistance

 

Thomas R. Hart II

tomhart@coopfed.org

  • Replies 3
  • Created
  • Last Reply
Guest Thomas R. Hart II
Posted

Re: scheduled task woes

 

Thomas R. Hart II wrote:

> Is there anybody out there that has any ideas, or something it seems

> like I didn't try yet? This task is a backup for our postgresql database

> that's pretty critical. We do have other scheduled tasks running

> properly on this machine as well. At this point I'm pretty stuck.

>

> TIA for any assistance

>

> Thomas R. Hart II

> tomhart@coopfed.org

 

Ok, so naturally I hack around for a week, finally send a message to a

ng, and 5 minutes later I get it working. Anyway the only thing I

changed is quoting the command and working-directory "C:\pg_backup.bat"

and "C:\" as opposed to C:\pg_backup.bat (note: no spaces here) and C:\

 

I have no clue why it wanted quotes around filenames with no spaces, but

it's working now, so like many things Microsoft I'll just assume it's

only working by way of some complicated magic that's impossible for the

human brain to comprehend

 

Until it stops working of course :-)

Guest Pegasus \(MVP\)
Posted

Re: scheduled task woes

 

 

"Thomas R. Hart II" <tomhart@coopfed.org> wrote in message

news:uspTXU8JIHA.6008@TK2MSFTNGP05.phx.gbl...

> Thomas R. Hart II wrote:

>> Is there anybody out there that has any ideas, or something it seems like

>> I didn't try yet? This task is a backup for our postgresql database

>> that's pretty critical. We do have other scheduled tasks running properly

>> on this machine as well. At this point I'm pretty stuck.

>>

>> TIA for any assistance

>>

>> Thomas R. Hart II

>> tomhart@coopfed.org

>

> Ok, so naturally I hack around for a week, finally send a message to a ng,

> and 5 minutes later I get it working. Anyway the only thing I changed is

> quoting the command and working-directory "C:\pg_backup.bat" and "C:\" as

> opposed to C:\pg_backup.bat (note: no spaces here) and C:\

>

> I have no clue why it wanted quotes around filenames with no spaces, but

> it's working now, so like many things Microsoft I'll just assume it's only

> working by way of some complicated magic that's impossible for the human

> brain to comprehend

>

> Until it stops working of course :-)

 

Things don't fix themselves. This problem will come back sooner

or later unless you fix it properly. There are two things you need

to be aware of::

- The error returned by scheduled tasks is generated by the

application, not by the task scheduler.

- Unless you post your batch file in full, nobody can tell you

what went wrong.

 

There is no "complicated magic" in this, just a lot of common sense.

Guest Thomas R. Hart II
Posted

Re: scheduled task woes

 

Pegasus (MVP) wrote:

> "Thomas R. Hart II" <tomhart@coopfed.org> wrote in message

> news:uspTXU8JIHA.6008@TK2MSFTNGP05.phx.gbl...

>> Thomas R. Hart II wrote:

>>> Is there anybody out there that has any ideas, or something it seems like

>>> I didn't try yet? This task is a backup for our postgresql database

>>> that's pretty critical. We do have other scheduled tasks running properly

>>> on this machine as well. At this point I'm pretty stuck.

>>>

>>> TIA for any assistance

>>>

>>> Thomas R. Hart II

>>> tomhart@coopfed.org

>> Ok, so naturally I hack around for a week, finally send a message to a ng,

>> and 5 minutes later I get it working. Anyway the only thing I changed is

>> quoting the command and working-directory "C:\pg_backup.bat" and "C:\" as

>> opposed to C:\pg_backup.bat (note: no spaces here) and C:\

>>

>> I have no clue why it wanted quotes around filenames with no spaces, but

>> it's working now, so like many things Microsoft I'll just assume it's only

>> working by way of some complicated magic that's impossible for the human

>> brain to comprehend

>>

>> Until it stops working of course :-)

>

> Things don't fix themselves. This problem will come back sooner

> or later unless you fix it properly. There are two things you need

> to be aware of::

> - The error returned by scheduled tasks is generated by the

> application, not by the task scheduler.

> - Unless you post your batch file in full, nobody can tell you

> what went wrong.

>

> There is no "complicated magic" in this, just a lot of common sense.

>

 

Thanks for the response, but I worry that you didn't read my original

post...

 

I had posted the full batch file (only two lines anyway), and I am aware

that return codes are not generated by the scheduler. Thanks to the

people at the postgresql mailing list (this was to do a postgres backup)

I did actually get this completely working, thanks to a cmd.exe /c

before the .bat file in the scheduled task command. (not sure why nobody

mentioned that?) As far as the magic comment, it was a poorly delivered

joke, and I apologize if you didn't get it.

 

Just to reiterate for anybody reading this, if you want to run a bat

file in a scheduled task, your task command should look like

"cmd.exe /c test.bat"

even though typing test.bat on the command line would work fine. I hope

this can help somebody avoid this particular pitfall.

 

Thanks for your replies everybody

 

Thomas R. Hart II

tomhart@coopfed.org


×
×
  • Create New...