Click to See Complete Forum and Search --> : run a script automatically at 4pm every day


hammerslane
11-28-2003, 04:11 AM
the subject says it all.... i want a script... or something which will automatically run a script (mail script, which sends a reminder to everyone in the office) at 4pm every afternoon.
it could sit on the server pc and be open all the time... but i want to use php to do it, and not some outlook reminder feature.
is there a way i could combine gmdate with if or something? or is there a specific function?
bear in mind i'm still fairly new at php... (3 months using it)

regards

Khalid Ali
11-28-2003, 06:31 AM
I am pretty sure you can not do that,and I tried to answer that in your last thread..

http://forums.webdeveloper.com/showthread.php?s=&threadid=22238

pyro
11-28-2003, 11:25 AM
If you are lucky enough to be on a Linux server, look into running a cron. It will do exactly what you want.

hammerslane
11-28-2003, 11:28 AM
darn... windows server :(

the reason i started a new thread for this, was beacuse i thought that as there was a specific gmdate function for seeing the time, there might be... er... i dunno

seems like i'll have to do it manually or use outlook

*grumbles about microsoft*

pyro
11-28-2003, 11:31 AM
This might help you: http://www.kalab.com/freeware/cron/cron.htm

hammerslane
11-28-2003, 11:58 AM
what language is the crontab file written in?
it looks like the right kind of thing... but i want to run a mail script... any help?

pyro
11-28-2003, 12:01 PM
I'm not sure exactly what you are asking. You could have the cron tab run a PHP script every day, and that can send out the mail (if you have a mail server).

hammerslane
11-28-2003, 12:04 PM
yea that's exactly what i'm asking... i have a mail server, and i want to know the code for running a script... there's a crontab file right? at the moment it's got stuff like # copy a file every half hour
0,30 * * * *copy c:\important.txt y:\i'm not sure what i should put in that file...

pyro
11-28-2003, 12:11 PM
To run a PHP script, something like this, probably:

0,30 * * * * php C:\path\to\your\script.php

Also, that will run once every 30 mins. To run it at 4pm every afternoon, try:

0 16 * * * php C:\path\to\your\script.php

hammerslane
12-01-2003, 10:29 AM
contents of my crontab file:# This is a sample crontab file. This file must be copied to the same directory as cron.exe
# A log is written to cron.log

# This is a comment. In fact, every line not starting with a number is treated as a comment.

30 16 * * * php \\Maze01\shared\Web\intranet\jobsheet\jobsubmit/alert.php

4:30pm came, and cron.exe just crashed on me, windows xp style.

:(
ah well - i'm sure i'll find another way... i hope.
thanks for the help pyro, you're tops :)

pyro
12-01-2003, 10:50 AM
This is probably part of the problem...

\\Maze01\shared\Web\intranet\jobsheet\jobsubmit/alert.php

hammerslane
12-01-2003, 10:54 AM
you speak the truth... my stupidity wins me over again! can i just ask, what's the 'php' before the file path for?

pyro
12-01-2003, 10:58 AM
Not sure if it would be needed on the windows version, but with Linux, it's used to let it know that a PHP script is coming.

hammerslane
12-01-2003, 11:09 AM
ah right... well i managed to get the script to run when i wanted it to. i didn't need the 'php' before the path.

thanks matey.

pyro
12-01-2003, 11:32 AM
You bet... :)

hammerslane
12-03-2003, 10:56 AM
update:
the cron.log files says that the sript has run at the specified time, and the script itself works. the only thing is, that when the script is run on schedule, it doesn't actually execute for some reason. although it finds the file, and says its run.

note: if i run the script manually, it works fine.

no ideas? i might have to look for something in windows that will do it

pyro
12-03-2003, 11:29 AM
My only idea would be to tell you to add the php back into the cron. Other than that, not sure, as I've not used the windows cron program.