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! |
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 .... |
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 Code:
php <script name>.php |
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 ;-) |
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 |
Thanks for the suggestion, Tinkster. Will mysqldump shutdown/stop mysql server while it's backup? My main object is to backup the database gracefully.
|
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. |
All times are GMT -5. The time now is 12:26 PM. |