Questions about cron and php script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Questions about cron and php script
# 1  
Old 03-23-2008
Questions about cron and php script

I'm trying to set up a php script that runs via crontab on a server. I've never done anything like this before.


My questions:

1) I want the crontab to run the script everyday from 3:58 PM to 4:13 PM EST. How is that written in crontab?

2) The command I want crontab to run is: php -q /path/to/script.php
According to that path name, where do I put the php script on my server? Do I have to create a folder named "path" with a folder named "to" in it, and put "script.php" in that folder?



More about question #1...

I can access my server through Cpanel (Hostgator). In Cpanel they provide two ways to enter a crontab. Here are screenshots showing both of those Cron Managers:
http://www.iov.in/cpanelcronmanagers.jpg


Because I want crontab to run the php script from 3:58 pm EST until 4:13 pm EST, I'm wondering how I am going to be able to enter that into either Cron Managers that Hostgator provides. There doesn't seem to be a way to enter a crontab so it starts 2 minutes before one hour (3 pm) and runs until 13 minutes after the next hour (4 pm).

Once someone does help me with the way the cronjob needs to be written, any ideas on how I enter that code into either one of the Cpanel Cron Managers? If I have to upload the crontab code to the server without using CPanel, how do I do that?
# 2  
Old 03-24-2008
You cannot define "from:to" time frames with cronjob, you can tell when to start. For the path, put the script outside of the ServerRoot, i.e. /home/script.php. For other host related questions it's best to ask the hosting provider's support staff.
# 3  
Old 03-24-2008
Normally, a cron job is executed, and it does whatever it does, and stops.

Sounds like you want it to run continuously until a certain time. If that's the case, you need to have the conditional loop within the script you are running.

If, instead, you want it to run every minute from 3:58 to 4:13, then simple enter two lines in the crontab document, such as:

58,59 15 * * * /path/script
0-13 16 * * * /path/script

The first like runs it at 3:58pm and 3:59pm. The second line runs it every minute from 4:00pm thru 4:13pm.

Note that this will execute it SIXTEEN times.
# 4  
Old 03-24-2008
nevermind............

Last edited by colin72; 03-31-2008 at 12:09 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. Shell Programming and Scripting

Technical questions on bash,mysql and pHp

1. bash -bash escape rules, esp. ',", -how to use Ctrl+R reverse cmd search with regex? 2. mysql -how to use grep in mysql 3. php -why !0 is not evaluated to true? what's its value -php getopt: what if there is duplicate in cmdline args (2 Replies)
Discussion started by: John_Peter
2 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script1.php'); system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script2.php'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

5. Shell Programming and Scripting

Running php from cron - working up to a point

Hi there, I am struggling to try and work out what is going wrong with a cron job i have running daily which opens up an imap mailbox and extracts a rar file to a directory on the web server. The script works ok when run manually, and when it is running from cron, I can see that it opens up the... (2 Replies)
Discussion started by: nicky77
2 Replies

6. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

7. UNIX for Advanced & Expert Users

Cron questions

Hello. I am using Solaris 10 (Sparc) and have a couple of questions regarding cron that I did not see answered in previous threads. Can you add just a user/login name to the cron.allow file or is only groups that are added? After adding a name or group to cron.allow, does cron need to be... (1 Reply)
Discussion started by: RobertSubnet
1 Replies

8. UNIX for Dummies Questions & Answers

script questions

Does anyone know how to use shell scripts to write the following if input is a b c d I wnat output as d c b a Thanks (2 Replies)
Discussion started by: james94538
2 Replies

9. UNIX for Dummies Questions & Answers

cron job to run php file

Hello, I have searched and searched google to do this and i want my websever to be able to run a php file everyday automatically. How do I go about doing this? Php is installed as an apache module not CGI. Thank you! (3 Replies)
Discussion started by: christo16
3 Replies

10. UNIX for Dummies Questions & Answers

Calling a PHP script from cron

This is a line from my crontab: 12 12 * * * /home/users/ElburdNDL/www/backups/adddate.php The permissions of the script is 755 it should execute ok....but it doesn't. Do I somehow have to give cron the path to PHP or something? If so, how exactly? Thanks. Ed PS Am a total newbie... (10 Replies)
Discussion started by: eludlow
10 Replies
Login or Register to Ask a Question