• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Scheduling a Task

I want to be able to schedule a script (hopefully php) to run at a specified tme each day.

How can I do that?
0
Richard Korts
Asked:
Richard Korts
4 Solutions
 
ozoCommented:
man crontab
0
 
AutogardCommented:
In "/etc" you will (should) find a "cron.daily" folder (/etc/cron.daily).  Any script in there will run at a certain time each day.

If you don't really care what time it gets run then this is a good way to go (if you do care then you will need to specify the time -- the method for doing this may be different depending on which distribution you are running -- for suse check here: http://lists.suse.com/archive/suse-linux-e/2005-May/1103.html -- it may be the same on your distro too).  If you want more control over your cron then check "man crontab".

Also, are you familiar with running php scripts from the command line?  To do so just run "php" or "php5" from the command line (so you may need to create a shell script that does this and put that shell script in your cron.daily folder).  Also be aware that a php script run from the command line may not run exactly as it would from the web (different method for handling variables, etc...)  Make sure you test it first.  Another trick is to run your php script using a text browser (lynx or w3m) on the command line instead of using "php" or "php5" directly (that way the variables will work as they usually do).
0
 
Richard KortsAuthor Commented:
To Autogard:

Thanks for that detail information.

I need to make this work on a remote web server. I only have ftp access to it.

Lets take a VERY SPECIFIC example.

Suppose I wanted a php script housed in a folder called c:/websites/rkassociates.com/LSS/ to be run at 2AM daily. Suppose further the script was called savetrans.php.

How EXACTLY would I do that?

Thanks
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
root_startCommented:
Hi rkorts,

What do you mean by: "I need to make this work on a remote web server. I only have ftp access to it."?
The script in one server and you need to execute it in another server where the web server is, also, you only have ftp access to this server?

If you only have ftp access to this server, you will not be able to execute it.

About cron, check the link below, it will help you to configure what you need and also will show how cron works. =0)
    - http://www.unixgeeks.org/security/newbie/unix/cron-1.html

I hope it helps. =0)
0
 
AutogardCommented:
Sorry for the delayed response...  Yeah, if you only have ftp access I don't think you will be able to use cron then to schedule your task.  You would need to have the remote server administrator agree to set up the cron for you.

Also, why would your php script be in c:/<whatever>?  I thought this was a linux question?  Is the server you want the cron to run on a windows/linux machine?

Here is a trick you could try though -- you could set up your own machine (through cron or otherwise) to automatically access the php page on the web server at 2AM just using a browser like firefox or even a text browser.  Of course your own machine would have to be turned on every morning at 2AM for this to work.  Is that something you would be interested in trying out?
0
 
PhreonxCommented:
Hello,
it's been like 20 days since the last post to this question and I don't even know if you have resolved your problem rkorts. Remote execution of commands via the FTP protocol is possible but since the command I'm about to tell you is not part of the formal FTP specification, this command is not official. Successful execution of this command depends entirely on whether the FTP Server has been setup to support it or not [default: NO and I believe you can understand why]. Anyway, the command is: site exec.
Since it is very unlikely to have enabled support for this command on the FTP Server, know that otherwise you cannot execute remote commands on any remote workstation/server VIA the FTP protocol. Howver, ssh is perhaps the way to go. But you will need to have it setup on the remote end. Ask your administrator for this.

Hope this helps ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now