Solved

Scheduling a Task

Posted on 2006-06-08
8
294 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Centos Boot Error 42 111
updating the repos in yum 4 107
Linux Hanging with disable Error Output 4 71
Linux "time" command output redirection 16 77
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

15 Experts available now in Live!

Get 1:1 Help Now