RewriteRule stopping cron job

Hi there,

In my public_html folder I have the following .htacces file:


Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} site1.com
RewriteCond %{REQUEST_URI} !^/site1
RewriteRule ^(.*)$ site1/$1 [L]

RewriteCond %{HTTP_HOST} site2.com
RewriteCond %{REQUEST_URI} !^/site2
RewriteRule ^(.*)$ site2/$1 [L]

I also have a cron job running the following command:


/usr/bin/php5 /home/sites/[i]{domain-name}[/i]/public_html/site2/backup_db.php

If I disable the .htaccess file, the cron job will execute, otherwise it wont. I’m not really sure why this is happening, since the cron job is using an absolute path to a file on the server, and not making any requests through the server. Isn’t it?

Has anyone come up with this sort of thing before?

Many thanks

Cron should not connect via the website, no, but maybe your PHP script is?

MG,

Rémon is correct about Adobe not running the CRON request.

I believe you have an error in your CRON code:


/usr/bin/php5 /home/sites/{domain-name}/public_html/site2/backup_db.php

I have a CRON job running using

/usr/local/bin/php -q /home/{account_name}/public_html/{php_script_name}

Given that it’s been working for me for over two years (on three accounts), I would recommend that you check your PHP executable location AND add the -q switch before the PHP filename that you want CRON to execute.

NOTE 1: I cannot find the meaning of the -q switch so it may not be necessary – just something to try if all else fails.

NOTE 2: DreamHost’s example is /usr/local/php5/bin/php /home/<USER NAME>/path/to/script.php, i.e., the php executable is in the binary directory of the php5 but does NOT use the -q switch.

Regards,

DK

Can you give us some background about what you script does? We don’t necessarily need to see the code, but I think ScallioXTX is on the right track here. I’d bet that your script is trying to connect to your website over HTTP and the cron job is interfering with that part of the script.

Boy, that became a difficult challenge and I’m not even sure I found the proper meaning in the way you used it. What I found states it suppressed html output in older cgi versions. In PHP 5.2 the -q was deprecated.

From: http://php.net/manual/en/features.commandline.php (first comment)

i use emacs in c-mode for editing. in 4.3, starting a cli script like so:

#!/usr/bin/php -q /* -- c -- */
<?php

told emacs to drop into c-mode automatically when i loaded the file for editing. the ‘-q’ flag didn’t actually do anything (in the older cgi versions, it suppressed html output when the script was run) but it caused the commented mode line to be ignored by php.

in 5.2, ‘-q’ has apparently been deprecated. replace it with ‘–’ to achieve the 4.3 invocation-with-emacs-mode-line behavior:

#!/usr/bin/php – /* -- c -- */
<?php

don’t go back to your 4.3 system and replace ‘-q’ with ‘–’; it seems to cause php to hang waiting on STDIN…

cp,

Thanks for that info. I was checking Apache.org for details on that (should have been a Linux website, I know :blush: ) and found nothing. Other website examples used the -q but gave no definition of that switch.

I hope Micky gave it a try both with and without and will report back here with results.

BTW, (belated) congrats on becoming a TL! Well deserved.

Regards,

DK

Not a problem, I had never seen that switch option before, so I was curious as to what it could possibly mean myself (and it was a challenge to find what little info about it I did find).

[ot]

Thanks![/ot]