Hey, we started the Linuxdoc.org blog. You want to write a guest post about your favorite Linux related topic? Just send us a mail.The Linux community would appreciate it.

Can anyone help me? I just need to call a php script from my server once in a hour on every day. I know that i can do i with a cronjob? Is that right? How do i manage to achieve this?

asked 18 May '11, 04:37

shellscripter's gravatar image

shellscripter
6113
accept rate: 0%


Hi Shellscripter,

To edit your cronjobs, execute this command:

crontab -e

Then you have two options. If your PHP script as executable rights (CHMOD 755), you should be able to simply call the script:

0 * * * /path/to/script.php

Just as reminder, the crontab format is: minute hour day month weekday command. So in this case we ask the cron to launch the script every week day, every day and every hour at HOUR:00 (08:00, 09:00, etc.).

If you want more info about crontab, you can go here: http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5.

link

answered 19 May '11, 03:46

sebastien's gravatar image

sebastien
16137
accept rate: 20%

<p>Hi sebastien, thanks for your help. Your piece of code isn't working out for me though. The problem is that the php script i want to open is located on an external server. How can i call it? Thanks in advance!</p>
(19 May '11, 07:01) shellscripter shellscripter's gravatar image
1
<p>Maybe using wget? </p> <p>0 * <em> * </em> /usr/bin/wget -q -O /dev/null <a href="http://www.yoursite.com/path/to/script.php">http://www.yoursite.com/path/to/script.php</a></p>
(19 May '11, 09:04) sebastien sebastien's gravatar image
<p>hey, works like a charme. Thanks!</p>
(19 May '11, 15:47) shellscripter shellscripter's gravatar image
-1

vim /etc/crontab

enter the correct format

link

answered 10 Nov '12, 12:21

sunsaincrypter's gravatar image

sunsaincrypter
151
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8
×1
×1
×1

Asked: 18 May '11, 04:37

Seen: 6,110 times

Last updated: 10 Nov '12, 12:21

we use OSQA