Scheduled Cron Jobs - Path Error

1 post / 0 new
#1 Sun, 11/04/2007 - 05:20
ADobkin

Scheduled Cron Jobs - Path Error

One of my users has a PHP file that runs out of cron. It works fine if he runs it from the command-line under his account, and it works fine when it runs automatically from cron. However, if he uses the Scheduled Cron Jobs module in Virtualmin and clicks the "Run Now" button, it fails with the following error:

PHP Warning: fopen(testfile.txt): failed to open stream: Permission denied ...

After doing some testing / debugging, I discovered that Webmin is setting the working directory (PWD) to /usr/libexec/webmin/cron/, instead of the user's home directory or the same directory of the file that is being called. In other words, the cron job is set to:

php /home/domain.com/public_html/testfile.php

The user is trying to open a file without a path name, as in "testfile.txt". He is expecting it to open in /home/domain.com/public_html, or possibly even in /home/domain.com.

Is this a bug in Virtualmin, or does the user simply need to set his working directory or full path names in his PHP file? Doing the latter should work, but if the script works properly out of cron when scheduled and run automatically, then it seems like the "Run Now" button should have the same behavior.