Solved

Scheduling a Task

Posted on 2006-06-08
8
295 Views
Last Modified: 2010-04-22
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
Comment
Question by:Richard Korts
8 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 16866142
man crontab
0
 
LVL 8

Assisted Solution

by:Autogard
Autogard earned 125 total points
ID: 16866507
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
 

Author Comment

by:Richard Korts
ID: 16873617
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Assisted Solution

by:root_start
root_start earned 125 total points
ID: 16874688
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
 
LVL 8

Expert Comment

by:Autogard
ID: 16874900
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
 
LVL 4

Assisted Solution

by:Phreonx
Phreonx earned 125 total points
ID: 17016617
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now