News:

Wondering if this will always be free?  See why free is better.

Main Menu

shell_exec hangs?

Started by MobileCS, June 29, 2017, 10:02:06 PM

Previous topic - Next topic

MobileCS

Is it possible to use shell_exec in sources/Subs-Post.php?

After pressing the "Post" button, the post gets posted but the browser continues to show the loading animation and just hangs on the editor screen indefinitely until it times out.

The code I am using is :

shell_exec("/usr/local/bin/php /www/example.com/forum/do-stuff.php &> /dev/null");

When I use this code is a stand alone php file, it works just fine without issues. However, adding in to Subs-Post.php causes it hang.

Am I doing something wrong?

vbgamer45

It should be.

Why are doing a shell exec to excute a php file on the same server?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

MobileCS

Using shell_exec, I can run the PHP process in the background so it's non blocking (performing a couple cURL commands).

vbgamer45

ok yeah i do something similar at times. I have a cron/task scheluded that looks for jobs to run. Then excites them like that behind the scenes. But the task is on it's cron/scheduled task loop.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

MobileCS

Ah, that method just might work for me ... I can store my information in MySQL and just use cron to check every 5 minutes for jobs to do.

MobileCS

Just wanted to post the solution before marking this as solved.

exec("/usr/local/bin/php /www/example.com/forum/do-stuff.php > /dev/null 2>&1 &");

The & symbol at the end triggers it to run as a background process.

Advertisement: