LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-23-2012, 11:30 AM   #1
pheaselegen
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Rep: Reputation: Disabled
Lightbulb Cron job for a php file


Hi all;
I need to execute a php file with SSH, once a day on my CentOS 5.6 server.
How can i do this?
(Note 1: php file including more commands so i can't open with a browser.)
(Note 2: i am a newbie and i googled many pages, but i didn't find.)
(Note 3: i am From Turkey and i am sorry for my poor English.)
 
Old 09-23-2012, 12:05 PM   #2
tulioribeiro
LQ Newbie
 
Registered: May 2012
Location: Brazil - Santa Catarina
Posts: 8

Rep: Reputation: Disabled
Maybe you can use lynx, lynx is a browser text mode.

ps.: lynx http://domain.com/?act1=x1&act2=makeThis

Regards.

Tulio Ribeiro.

Last edited by tulioribeiro; 09-23-2012 at 12:11 PM. Reason: Put a example.
 
Old 09-23-2012, 12:17 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,704

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Welcome to LinuxQuestions

What does your php script do? It is possible to run them from the command line.
If would help to tell us what you are trying to accomplish.
 
Old 09-23-2012, 12:21 PM   #4
pheaselegen
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for your answers. My script compling a big (8 MB)xml file. And adding all to a database. I am making manually in ssh with following command:
php script.php

But i want to do this automaticly once a day.
Thanks again.
 
Old 09-23-2012, 12:49 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,704

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
I would set up public/private keys. This will allow you to run a cron script and not have to deal with entering a password. You can also make your script executable by adding #!/usr/bin/php shebang as the first line and change its permissions to executable.

You can run the php script and your other commands from a single script and call it from cron. Executing the script remotely via cron is as simple as

10 10 * * * ssh user@server "/path/to/my_script"
 
Old 09-23-2012, 01:12 PM   #6
_dkode_
LQ Newbie
 
Registered: Sep 2012
Location: kerala
Distribution: debian
Posts: 11

Rep: Reputation: 0
simply set up a cron job in your server, this will invoke the script automatically.

to set up cron job ssh to the server and use: crontab -e
and set the cron entry
30 10 * * * /usr/bin/php /absolute/path/to/your/php/script

this will execute your php script at 10:30 AM everyday.
 
Old 09-23-2012, 02:54 PM   #7
pheaselegen
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you all...
 
  


Reply



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
Cron Job - FTP Upload File script stuartornum Linux - General 3 09-23-2012 12:34 PM
cron job running PHP script to update MySQL - access denied error Beauford2008 Linux - Newbie 9 09-24-2008 07:17 PM
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron job that email a text file paynsr Linux - Newbie 1 03-29-2004 01:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:49 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