?
Solved

Scheduling a Task

Posted on 2006-06-08
8
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 84

Accepted Solution

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

Assisted Solution

by:Autogard
Autogard earned 500 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 3

Assisted Solution

by:root_start
root_start earned 500 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 500 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

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

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

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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 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