Welcome to WebmasterWorld Guest from 54.158.54.179

Forum Moderators: bill

Message Too Old, No Replies

HELP PLEASE: running a cmd from scheduled tasks

cron job

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

5+ Year Member



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.

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

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Can you put the commands into a batch file and run that instead?
3:41 am on Oct 22, 2009 (gmt 0)

5+ Year Member



i dont know how to do that
3:46 am on Oct 22, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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.
4:00 am on Oct 22, 2009 (gmt 0)

5+ Year Member



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

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

5+ Year Member



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!

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

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.)

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

WebmasterWorld Senior Member 5+ Year Member



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..
3:04 am on Oct 23, 2009 (gmt 0)

5+ Year Member



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.

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

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month