<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Running PHP Scripts with Cron</title>
	<atom:link href="http://www.htmlcenter.com/blog/running-php-scripts-with-cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/</link>
	<description>Web Development Help and Tutorials</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:25:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Todor Pavlov</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-27904</link>
		<dc:creator>Todor Pavlov</dc:creator>
		<pubDate>Sun, 09 Oct 2011 19:04:04 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-27904</guid>
		<description>The best solution for  me is to create only one cron job which runs every minute:
* * * * * php /path/to/your/cron.php

and then to make web interface to execute as many scripts as you want in what time you want. The names of the scripts and the time for execution can be written in the database and executed with system() php function</description>
		<content:encoded><![CDATA[<p>The best solution for  me is to create only one cron job which runs every minute:<br />
* * * * * php /path/to/your/cron.php</p>
<p>and then to make web interface to execute as many scripts as you want in what time you want. The names of the scripts and the time for execution can be written in the database and executed with system() php function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: doyanet</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-22657</link>
		<dc:creator>doyanet</dc:creator>
		<pubDate>Wed, 09 Mar 2011 04:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-22657</guid>
		<description>Hi,

I am going to run crontab job on php by using GET parameter. Does it work?.

for e.g:
1 * * * * c:\php.exe c:\test.php?action=fruits

I tested and failed. Is there any way to run php file but using GET paramenter as I described above?.

So, if it could works, will be easier for me to maintain function/ code only in a single php file.

Thanks.
Doya.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am going to run crontab job on php by using GET parameter. Does it work?.</p>
<p>for e.g:<br />
1 * * * * c:\php.exe c:\test.php?action=fruits</p>
<p>I tested and failed. Is there any way to run php file but using GET paramenter as I described above?.</p>
<p>So, if it could works, will be easier for me to maintain function/ code only in a single php file.</p>
<p>Thanks.<br />
Doya.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fullia</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-22561</link>
		<dc:creator>Fullia</dc:creator>
		<pubDate>Mon, 07 Mar 2011 22:23:50 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-22561</guid>
		<description>I use Dashboard, but this code does not work. What could be the reason?

&lt;code&gt;php -q /domains/sitename.com/public_html/phpfilename.php&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I use Dashboard, but this code does not work. What could be the reason?</p>
<p><code>php -q /domains/sitename.com/public_html/phpfilename.php</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefano</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-21062</link>
		<dc:creator>Stefano</dc:creator>
		<pubDate>Wed, 02 Feb 2011 19:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-21062</guid>
		<description>I have php as apache module, lynx is not possible install.
with wget not succesfully operation
with curl not succesfully operation

my script php content:
ThisPath = realpath( dirname(__FILE__) ); 
include($ThisPath.&#039;/../config_db.php&#039;);
/** link al db */
$link = mysql_connect($DB_host,$DB_login,$DB_password);
if (!$link) {
    die(&quot;\r \n Impossibile connettersi: &quot;.mysql_error());
} else {
    echo &quot;\r \n Connesione eseguita a: &quot;.$DB_host;
}
/** Select DB */
$db_selected = mysql_select_db($Application[&quot;dati&quot;], $link);
if (!$db_selected) {
    die (&quot;\r \n Impossibile utilizzare: &quot;.mysql_error());
} else {
    echo &quot;\r \n Selezione del DB: &quot;;    
}
$backupFile= $ThisPath.&#039;/&#039;.$Application[&quot;dati&quot;] . date(&quot;Y-m-d-H-i-s&quot;) . &#039;.gz&#039;;
echo $Application[&quot;dati&quot;];
$command=&#039;mysqldump --opt -h &#039;.$DB_host.&#039; -u&#039;.$DB_login.&#039; --password=&#039;.$DB_password.&#039; -A &#124; gzip &gt; &#039;.$backupFile;
echo $command;
system($command);

string $command result:
mysqldump --opt -h 127.0.0.1 -u root --password=password -A &#124; gzip &gt; /var/www/BK_db/db2011-02-02-13-15-36.gz

why?</description>
		<content:encoded><![CDATA[<p>I have php as apache module, lynx is not possible install.<br />
with wget not succesfully operation<br />
with curl not succesfully operation</p>
<p>my script php content:<br />
ThisPath = realpath( dirname(__FILE__) );<br />
include($ThisPath.&#8217;/../config_db.php&#8217;);<br />
/** link al db */<br />
$link = mysql_connect($DB_host,$DB_login,$DB_password);<br />
if (!$link) {<br />
    die(&#8220;\r \n Impossibile connettersi: &#8220;.mysql_error());<br />
} else {<br />
    echo &#8220;\r \n Connesione eseguita a: &#8220;.$DB_host;<br />
}<br />
/** Select DB */<br />
$db_selected = mysql_select_db($Application["dati"], $link);<br />
if (!$db_selected) {<br />
    die (&#8220;\r \n Impossibile utilizzare: &#8220;.mysql_error());<br />
} else {<br />
    echo &#8220;\r \n Selezione del DB: &#8220;;<br />
}<br />
$backupFile= $ThisPath.&#8217;/&#8217;.$Application["dati"] . date(&#8220;Y-m-d-H-i-s&#8221;) . &#8216;.gz&#8217;;<br />
echo $Application["dati"];<br />
$command=&#8217;mysqldump &#8211;opt -h &#8216;.$DB_host.&#8217; -u&#8217;.$DB_login.&#8217; &#8211;password=&#8217;.$DB_password.&#8217; -A | gzip &gt; &#8216;.$backupFile;<br />
echo $command;<br />
system($command);</p>
<p>string $command result:<br />
mysqldump &#8211;opt -h 127.0.0.1 -u root &#8211;password=password -A | gzip &gt; /var/www/BK_db/db2011-02-02-13-15-36.gz</p>
<p>why?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vebh</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-20079</link>
		<dc:creator>Vebh</dc:creator>
		<pubDate>Fri, 07 Jan 2011 08:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-20079</guid>
		<description>i want to start my automatic newsletter section through in queue sending, right now i am with proper setting from Magento panel for my site, please suggest me a best solution for newsletter queue.</description>
		<content:encoded><![CDATA[<p>i want to start my automatic newsletter section through in queue sending, right now i am with proper setting from Magento panel for my site, please suggest me a best solution for newsletter queue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-19894</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sat, 01 Jan 2011 22:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-19894</guid>
		<description>I was having a problem setting up a cron job, but after reading your post I was able to fix it - thank you!</description>
		<content:encoded><![CDATA[<p>I was having a problem setting up a cron job, but after reading your post I was able to fix it &#8211; thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-19676</link>
		<dc:creator>Randy</dc:creator>
		<pubDate>Sun, 26 Dec 2010 17:20:45 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-19676</guid>
		<description>Thanks... this was the info I needed to get my first PHP cron running.</description>
		<content:encoded><![CDATA[<p>Thanks&#8230; this was the info I needed to get my first PHP cron running.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sanantone</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17705</link>
		<dc:creator>sanantone</dc:creator>
		<pubDate>Fri, 10 Dec 2010 20:40:54 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17705</guid>
		<description>why not install php-cli?

then write your php script with the shebang in the first line (path must be to your php executable, -q is optional now i believe)

#!/usr/bin/php -q

followed by typical php stuff, example

&lt;?php echo php_info();

the resulting script file can be executed from the command line:
php myphpinfoscript.php

or if you chmod myphpinfoscript.php as executable, then simply run it as
./myphpinfoscript.php

the .php is optional too</description>
		<content:encoded><![CDATA[<p>why not install php-cli?</p>
<p>then write your php script with the shebang in the first line (path must be to your php executable, -q is optional now i believe)</p>
<p>#!/usr/bin/php -q</p>
<p>followed by typical php stuff, example</p>
<p>&lt;?php echo php_info();</p>
<p>the resulting script file can be executed from the command line:<br />
php myphpinfoscript.php</p>
<p>or if you chmod myphpinfoscript.php as executable, then simply run it as<br />
./myphpinfoscript.php</p>
<p>the .php is optional too</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ige</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17364</link>
		<dc:creator>ige</dc:creator>
		<pubDate>Mon, 06 Dec 2010 09:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17364</guid>
		<description>sorry, my typo error in comment #32
 
in d)  but when i am in a bash shell prompt ...
...
and i issue
lynx -dump http://localhost/webroot/x.php

should read 
lynx -dump http://localhost/webroot/yy.php

thanks again for any leads</description>
		<content:encoded><![CDATA[<p>sorry, my typo error in comment #32</p>
<p>in d)  but when i am in a bash shell prompt &#8230;<br />
&#8230;<br />
and i issue<br />
lynx -dump <a href="http://localhost/webroot/x.php" rel="nofollow">http://localhost/webroot/x.php</a></p>
<p>should read<br />
lynx -dump <a href="http://localhost/webroot/yy.php" rel="nofollow">http://localhost/webroot/yy.php</a></p>
<p>thanks again for any leads</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ige</title>
		<link>http://www.htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17214</link>
		<dc:creator>ige</dc:creator>
		<pubDate>Fri, 03 Dec 2010 08:06:04 +0000</pubDate>
		<guid isPermaLink="false">http://htmlcenter.com/blog/running-php-scripts-with-cron/#comment-17214</guid>
		<description>i am having difficulty with running a php script at the shell prompt for testing.  
can somebody enlighten me?  
or point me to sites which explain relevant things i need to understand.  
many thanks. 

i have these :
a) ubuntu 8.04 LTS, apache, php, mysql, bash

b) directory:  ../webroot/
-rwxr-xr-- 1 root root 6.9K 2010-12-01 18:31 yy.php

this is a php script that reads log files at /var/www/ylogs and 
converts contents to records into a mysql table. 
i hope to run this script in cron later after a successful testing.

c) directory:  /var/www/ylogs
-rwxrwx--- 1 www-data root      185 2010-12-03 15:08 tallyA
-rwxrwx--- 1 www-data root      185 2010-12-03 15:08 tallyB
...
...
-rwxrwx--- 1 www-data root      185 2010-12-03 15:08 tallyZ

d) what happens :
when i try entering http://localhost/webroot/yy.php at the URL field in Firefox,
the script works.

but when i am in a bash shell prompt and i try :
sudo -i (i enter password of the default-sudoer-user, i am given this prompt)
root@name-of-computer :~# 
and i issue 
lynx -dump http://localhost/webroot/x.php

it gives me this error :
Connection to 127.0.0.1 failed, (111) Connection refused

but when i logout from root into 
default-sudoer-user@name-of-computer :~$ 
and i issue 
lynx -dump http://localhost/webroot/yy.php
it works

when i log as a regular user (non-sudoer)
regular-user@name-of-computer :~$
and i issue 
lynx -dump http://localhost/webroot/yy.php
it also works.

when the tally logs are owned as root:root, i get permission denied when i run the script, 
but when the tally logs are chowned as www-data:root, the script runs.

e) some questions :
in bash (and later cron), what user should i run the script yy.php as?
(and also in apache/php, my understanding is it should be www-data?) 

if several computers are to submit their respective tallies 
via a cronned scp into this /var/www/ylogs directory, 
should i give these computers login access as user www-data 
so that apache/php can run the script? 
is this secure? 

i am so confused, any help will be appreciated.  
and sorry for a very long post.</description>
		<content:encoded><![CDATA[<p>i am having difficulty with running a php script at the shell prompt for testing.<br />
can somebody enlighten me?<br />
or point me to sites which explain relevant things i need to understand.<br />
many thanks. </p>
<p>i have these :<br />
a) ubuntu 8.04 LTS, apache, php, mysql, bash</p>
<p>b) directory:  ../webroot/<br />
-rwxr-xr&#8211; 1 root root 6.9K 2010-12-01 18:31 yy.php</p>
<p>this is a php script that reads log files at /var/www/ylogs and<br />
converts contents to records into a mysql table.<br />
i hope to run this script in cron later after a successful testing.</p>
<p>c) directory:  /var/www/ylogs<br />
-rwxrwx&#8212; 1 www-data root      185 2010-12-03 15:08 tallyA<br />
-rwxrwx&#8212; 1 www-data root      185 2010-12-03 15:08 tallyB<br />
&#8230;<br />
&#8230;<br />
-rwxrwx&#8212; 1 www-data root      185 2010-12-03 15:08 tallyZ</p>
<p>d) what happens :<br />
when i try entering <a href="http://localhost/webroot/yy.php" rel="nofollow">http://localhost/webroot/yy.php</a> at the URL field in Firefox,<br />
the script works.</p>
<p>but when i am in a bash shell prompt and i try :<br />
sudo -i (i enter password of the default-sudoer-user, i am given this prompt)<br />
root@name-of-computer :~#<br />
and i issue<br />
lynx -dump <a href="http://localhost/webroot/x.php" rel="nofollow">http://localhost/webroot/x.php</a></p>
<p>it gives me this error :<br />
Connection to 127.0.0.1 failed, (111) Connection refused</p>
<p>but when i logout from root into<br />
default-sudoer-user@name-of-computer :~$<br />
and i issue<br />
lynx -dump <a href="http://localhost/webroot/yy.php" rel="nofollow">http://localhost/webroot/yy.php</a><br />
it works</p>
<p>when i log as a regular user (non-sudoer)<br />
regular-user@name-of-computer :~$<br />
and i issue<br />
lynx -dump <a href="http://localhost/webroot/yy.php" rel="nofollow">http://localhost/webroot/yy.php</a><br />
it also works.</p>
<p>when the tally logs are owned as root:root, i get permission denied when i run the script,<br />
but when the tally logs are chowned as www-data:root, the script runs.</p>
<p>e) some questions :<br />
in bash (and later cron), what user should i run the script yy.php as?<br />
(and also in apache/php, my understanding is it should be www-data?) </p>
<p>if several computers are to submit their respective tallies<br />
via a cronned scp into this /var/www/ylogs directory,<br />
should i give these computers login access as user www-data<br />
so that apache/php can run the script?<br />
is this secure? </p>
<p>i am so confused, any help will be appreciated.<br />
and sorry for a very long post.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

