LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2012, 02:26 PM   #1
Ne0Geek
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
CentOS 5x - How to launch PHP script


I am running AWS image with MySQL server installed. I am trying to run a php DB backup script but have a few basic questions. I have installed php. Is there a specific dir where all php scripts must reside/ launched from?

I have searched several forums but none address such basic questions...thx for the help!
 
Old 04-16-2012, 04:18 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, welcome to LQ!

First things first: what is this AWS you're referring to?

In general PHP scripts are "launched" (run/executed/...) in a web-environment.

If AWS (?) expects other means, try using cron, the OSes way of executing
scheduled tasks.


Cheers,
Tink



P.S.: When asking questions it's sound to assume that people know nothing about
your set-up, so providing essential information ahead of time is going to give
you a far better chance of helpful responses.
E.g.:
I'm running AWS, a <.......> product on a LAMP stack w/ apache2 2.1.14 on
moohluntu 10.10 ....
 
1 members found this post helpful.
Old 04-16-2012, 04:21 PM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
PHP (PHP hypertext Preprocessor) is mostly a web based language for creating web appliations. However it does have command line access when you install the php-cli modules. So to answer your questions you can try by typeing the following to get the include_paths which contain the default scripts used by the php language engine
Code:
php -i | grep include_path
or you can execute a script by typing
Code:
php <script name>.php
 
1 members found this post helpful.
Old 04-16-2012, 05:17 PM   #4
Ne0Geek
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks guys for your responses. Allow me to clarify, AWS stands for Amazon Web Services. I have a virtual machine running an image of CentOS 5x hosting MYSQL. I want to automate backups of several schema. To accomplish this I am using a php script that I run from terminal. Eventually I would like to run a cron job, but at this point I'm simply testing out the script. Since I am an absolute newbie, I was trying to rule out that I had placed the backup script in the incorrect dir to account for the errors that I am getting (e.g. :command not found, /: is a directory, and syntax error)

php -1 | grep include_path yielded this:

.:/usr/share/pear:/usr/share/php =>.:/usr/share/pear:/usr/share/php

I don't know what this means. Is this the dir I should execute .php from?

I tried to > result of script to a txt file, but is resulted in an empty file:

./php_script.php > ~/user/dir/errorlog.txt


Again, thank you very much for the help ;-)
 
Old 04-16-2012, 05:38 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well.. if you're using MySQL I'd not bother trying to take back-ups from
php; unnecessary overhead.

Have a look at
Code:
man mysqldump

Unless you need to be able to do ad-hoc backups via a webinterface, that is.
But even then it's probably easiest to install myPHPadmin, and do it from
there ...



Cheers,
Tink
 
1 members found this post helpful.
Old 04-16-2012, 06:13 PM   #6
Ne0Geek
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the suggestion, Tinkster. Will mysqldump shutdown/stop mysql server while it's backup? My main object is to backup the database gracefully.
 
Old 04-16-2012, 06:48 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
mysqldump locks the DB internally to guarantee a consistent data set, which is why its recommended to use that instead of doing your own code.
https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

For cron http://www.adminschoice.com/crontab-quick-reference.
NB: cron has a minimal env inc PATH settings, so always specify complete/absolute paths to cmds and files used by a cron job.
 
1 members found this post helpful.
  


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
CentOS VPS looking to launch firefox lsteacke Linux - Server 1 06-04-2011 09:01 PM
[SOLVED] how to launch Disk Druid after CentOS installation? avee137 Linux - Newbie 2 05-20-2010 11:12 PM
CentOS: how to launch it into rescue mode? concoran Linux - Newbie 1 05-23-2008 07:24 AM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 07:21 PM
PHP script to launch at start Black187 Linux - Software 1 04-25-2006 06:13 AM


All times are GMT -5. The time now is 02:34 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration