homepage Welcome to WebmasterWorld Guest from 54.204.90.135
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Deprecated - Microsoft Windows OS (XP/NT/Vista)
Forum Library, Charter, Moderators: bill

Deprecated - Microsoft Windows OS (XP/NT/Vista) Forum

    
HELP PLEASE: running a cmd from scheduled tasks
cron job
miketheman




msg:4011219
 1:21 am on Oct 22, 2009 (gmt 0)

Hi everyone,
I desperately need help with structing this scheduled task. I'm trying to have it execute a cron job for my website and it's not working at least from one line.

FROM CMD, it works fine from one line:
cd C:\Program Files\PHP & php -f tester.php & exit

FROM SCHEDULED TASK, not so much:
Run: C:\WINDOWS\system32\cmd.exe & cd C:\Program Files\PHP & php -f tester.php & exit
Start in: C:\WINDOWS\system32\

This just results in opening the dos terminal.

Can anyone suggest how I can run this command from a scheduled tasks....feel like I;m almost there.

GREATLY APPRECIATE IT.

 

bill




msg:4011252
 2:23 am on Oct 22, 2009 (gmt 0)

Can you put the commands into a batch file and run that instead?

miketheman




msg:4011278
 3:41 am on Oct 22, 2009 (gmt 0)

i dont know how to do that

youfoundjake




msg:4011280
 3:46 am on Oct 22, 2009 (gmt 0)

Save the command in notepad and save the file as cron.bat and make sure that the file type is set to all, otherwise you'll have a file name called cron.bat.txt
Then go into Scheduled tasks and set a task to run at whatever day and time you want, and point it to the .bat file.

miketheman




msg:4011286
 4:00 am on Oct 22, 2009 (gmt 0)

THANK YOU SO MUCH youfoundjake and bill for your guys help.

would this be the command:
C:\WINDOWS\system32\cmd.exe & cd C:\Program Files\PHP & php -f tester.php & exit

or this:
cd C:\Program Files\PHP & php -f tester.php & exit

miketheman




msg:4011290
 4:07 am on Oct 22, 2009 (gmt 0)

THANK YOU SO MUCH FOR ALL YOU GUYS GUIDANCE!

I got it working now. If others need to know.
Run: (This is your .bat file, my example is below)
Start In: C:\WINDOWS\system32\ (I pointed this to where cmd.exe is)

If anyone else finds this useful, please thank Bill and Jake above.

I tried everything to find this guidance online and couldn't. If you like me and you stumble upon this forum (for me, it's alot), register and say thanks to them.

THANK YOU GUYS!

bill




msg:4011310
 5:10 am on Oct 22, 2009 (gmt 0)

Glad that worked for you Mike.

You can probably skip the C:\WINDOWS\system32\cmd.exe portion and just list the command for your PHP in the batch file.

To test this open C:\WINDOWS\system32\cmd.exe manually, CD to the directory where you saved the batch file, and simply type the batch file name, and hit Enter. You should return to a prompt after the batch runs, or you'll see any error messages associated. Running a batch file from the GUI will often flash by too quickly to let you see if it worked or not (or if there were error messages.)

youfoundjake




msg:4011971
 1:55 am on Oct 23, 2009 (gmt 0)

You can also add a pause on the next line in the batch file which will keep the window open until you hit a key, which will close it out. That way, if there are errors, they will still be on the screen..

miketheman




msg:4012002
 3:04 am on Oct 23, 2009 (gmt 0)

Thank you so much guys for your support! The script works great, right now I'm looking up a command to hide it from opening....but anyways, I'll be away from my come for the next hour or so American Chopper is back on. (lol)

If anyone knows a way to prevent the dos window from opening but still run the script, that would be awesome if you could let me know.

bill




msg:4012014
 3:54 am on Oct 23, 2009 (gmt 0)

The easiest way would probably be to create a shortcut to the .bat file, and then set the properties of the shortcut to run Minimized. However, it will still be visible in the task bar.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Deprecated - Microsoft Windows OS (XP/NT/Vista)
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved