I'm trying to run a cron job on my web server. I used the cron module at the cPanel to add the file and used this command..
sh ./public_html/crark/run.sh
The problem was that it takes the root folder context for all the followed processes i.e. I call run.sh from cron job which has the following code

./public_html/test/test.exe -h -s > ./public_html/test/output.txt

The code apparently doesn't work as ./test calls a few files within that folder. I originally used

./test -h -s > output.txt

as the code inside run.sh because I wanted it to work in that directory context. It would be nice if someone told me how I can get this done. I have to use cron jobs because my web host disabled exec(),passthru() and other such commands in PHP to get my exe running! The problem I right now have is that ./test calls some files in that folder but due to context it doesn't work. Plus ./test source code isn't with me so that's a bummer! :(

Member Avatar for LastMitch

I have to use cron jobs because my web host disabled exec(),passthru() and other such commands in PHP to get my exe running! The problem I right now have is that ./test calls some files in that folder but due to context it doesn't work. Plus ./test source code isn't with me so that's a bummer! :(

Are you using windows? Read this:

http://windows.microsoft.com/en-US/windows7/schedule-a-task

Can you post your PHP code since you mention the command is not working.

There is no point in posting the PHP code because I know for sure that it wont work. The web host disabled those functions. I just need the cronjob done properly. And by the way how can one use sh and ./filename to execute on Windows? I'm obviously using Unix-based machine

commented: Don't be a SmartA$$ when someone is trying to help you -3
Member Avatar for LastMitch

The web host disabled those functions. I just need the cronjob done properly. And by the way how can one use sh and ./filename to execute on Windows? I'm obviously using Unix-based machine

Don't be a smarta$$ when someone is trying to help you.

The issue you are having is a bit complicate for any members (including me, noones is perfect) to help if you expect a member to help you any way please be patience and explain the issue in more detail instead of being upset for a response.

When you run a cron job it's usually permission issue. And please refrain yourself downvoting on me.

Good Luck if someone would help you with that kind of attitude.

Sorry to hurt you feelings Mitch. I've removed that down vote. My bad! This issue being a pain in the ass. Well anyways since you weren't able to find it I need to try asking some of my professors. Possibly they might know. Or maybe some good Linux book might have idea on how to change the current context. Thanks for your quick response!

Hello,

Since you mention cron I am assuming a Linux system. You have to remember that cron does not work like a normal user. You have to provide the absolute path of the files you want to run and set variables to allow it to run. If you are tring to run a php script from cron here is a site that covers several ways to execute the script:
http://www.thegeekstuff.com/2011/07/php-cron-job/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.