LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 01-29-2004, 03:05 AM   #1
airbuzz
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Rep: Reputation: 0
Calling a Php file from CRON every hours ?


Hi there !

I need to call a php file from cron every hour !
I don t know how to get rid with that does anybody can help ?

Thanks
 
Old 01-29-2004, 12:41 PM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
/var/cron/tabs/username:
0 0-23 * * * /path/to/executable/phpscript

Techinically you should edit this with `crontab -e` I have had a horrible time doing this though. Your best bet is to edit it with that command and make a note of the temp file it creates. If, for some reason the file isn't copied the the right directory manually move it (you will need to be root). If /var/cron/allow exists you MUST be listed in there. If /var/cron/deny exists you MUST NOT be listed in there. Hope this helps.
 
Old 01-30-2004, 03:07 AM   #3
airbuzz
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks, i finally find some more informations about cron but it stills don t work ..here 's what my cron looks like !

Code:
SHELL=/bin/sh
0 0 * * * cd /usr/home/addic1/usr/local/urchin; ./urchin >> ./log 2>&1
0 0 * * 0 /usr/local/bin/vsmtprelay exprire  
00 * * * * wget -q http://myadress/myscript.php
i aslo tried that
Code:
00 * * * * wget -q -O http://myadress/myscript.php
00 * * * * wget  http://myadress/myscript.php
00 * * * * curl -s -o /dev/null  http://myadress/myscript.php
00 * * * * /usr/local/curl -s -o  /dev/null  http://myadress/myscript.php
does anybody have an idea please help !!!
 
Old 01-30-2004, 03:11 AM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
You want it to run at midnight every day? I thought you wanted it to run once every hour?

Once every hour would be
0 0-23 * * * wget -q -O http://myadress/myscript.php
etc...

Note: Don't start it like a shell script it isn't one. It just has to be in /var/cron/tabs/ as your username... cron will find and run it.
 
Old 01-30-2004, 03:23 AM   #5
airbuzz
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Original Poster
Rep: Reputation: 0
yes i want to start it everyhour ...but why -23 in your exemple ?
sorry but what has to be in /var/cron/tabs/
may be it s astudip question but i am a

This is the way i edit my crontab :
edit etc/crontab.save
then i save this way
crontab etc/crontab.save;

THANKS Frob 23

Last edited by airbuzz; 01-30-2004 at 03:34 AM.
 
Old 01-30-2004, 03:30 AM   #6
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Okay, first the fields.

minute hour etc.

We want it to run on the 0th minute (start of the hour) and we want it to run on all the hours... from midnight through 11pm... 0-23 (military time... that is a selection of the hours we want.) We could run it every other hour with 0-23/2 the man page goes into detail about this. We leave the rest as *s because we don't want those values to affect when it runs.

User cron tabs are kept seperate from the system cron table. This allows you to change them without screwing up the important logs. They are kept in a file: /var/cron/tabs/frob23 (for example) That file would contain the lines in the format described in crontab's manpage. Aka... the same one I have been giving.

/var/cron/tabs/frob23: (the filename this is not in the file itself)
0 0-23 * * * /path/to/my/program with the arguments after it.

I hope this helps.
 
Old 01-30-2004, 04:13 AM   #7
airbuzz
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Original Poster
Rep: Reputation: 0
here is the way i edit cron

edit etc/crontab.save
then i save this way
crontab etc/crontab.save;

i had your line 0 0-23....

But it don t work
There s something i don t understand , i don t have those folder
var/cron/tabs/airbuzz
but i have usr/home/airbuzz which leads me to my home directory; i run a virtual server apache

THANKS 4 your time Frob 23
 
Old 01-30-2004, 04:41 AM   #8
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Do you have /var/cron/ ? /var/cron/tabs/ ? If you have /var/cron you can mkdir tabs. You will not have airbuzz (a text file) there until you make it.

Yeah, editing /etc/crontab that way will not work. Different format...
 
Old 02-02-2004, 02:36 AM   #9
airbuzz
LQ Newbie
 
Registered: Jan 2004
Posts: 5

Original Poster
Rep: Reputation: 0
fine ...i finally find the answer

0 0- 23 * * * /usr/bin/wget -q http://mysite/myscripts

thanks for your help Frob 23
 
Old 02-03-2004, 01:40 PM   #10
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
Originally posted by frob23
We want it to run on the 0th minute (start of the hour) and we want it to run on all the hours... from midnight through 11pm... 0-23 (military time... that is a selection of the hours we want.) We could run it every other hour with 0-23/2 the man page goes into detail about this. We leave the rest as *s because we don't want those values to affect when it runs.
The * means every possible matching value. In the hour field, this equates to 0-23. In the minute column, this equates to 0-59. Leaving the other fields as * means any day of week, any day of month, etc.

Quote:

/var/cron/tabs/frob23: (the filename this is not in the file itself)
0 0-23 * * * /path/to/my/program with the arguments after it.
This is also the same as:
0 * * * * /path/to/my/program

Quote:

Note: Don't start it like a shell script it isn't one. It just has to be in /var/cron/tabs/ as your username... cron will find and run it.
You can run PHP scripts from the command line just like any other script if they are properly written.
 
Old 02-03-2004, 02:04 PM   #11
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
The quote about it not being a shell script was refering to the crontab file. There is no need to set the shell type in user cron files. And, yes you can run anything like a normal program as long as you have the proper shell or interperter after the #!... You are right about the * being equal to all possible values. I have weird conventions sometimes; the 0-23 being one of them. I think it makes it easier to remember what I was doing without thinking about it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Calling Ant buildfile from cron pcdude Programming 9 10-20-2004 05:11 AM
Can I run localhost/file.php with CRON function kondor5 Linux - General 1 03-28-2004 06:44 AM
Daily Cron jobs with a PHP file Gargomel7 Programming 7 09-13-2003 07:21 PM
Cron/Vixie runs jobrotate 6 hours late SEL Linux - General 0 04-21-2002 04:56 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration