1

My html directory is becoming bloated so I am trying to reorganize the files. I have a few scripts that I have running on a cron job and I want to move them out of the html directory.

For example:

cronjob: php /chroot/home/mydomain/html/restock.php

restock.php:

<?php
require_once('app/Mage.php');
umask(0);
Mage::app();

my script

?>

What I would like is a directory called 'myscripts' or similar and have all my scripts sitting in there. My question is what is the best practice for this and also how would I modify my php scripts and cronjob???

1 Answer 1

1
require_once 'abstract.php';

class Mage_Shell_Restock extends Mage_Shell_Abstract {       
    protected $_stock;
    public function run()
    {
        if(true) {          
            //process your logic
        } else {
            echo $this->usageHelp();
        }
    }

    /**
     * Retrieve Usage Help Message
     *
     */
    public function usageHelp()
    {
        return <<<USAGE
Usage:  php -f restock.php -- [options]  
  help              This help
USAGE;
    }
}

$shell = new Mage_Shell_Restock();
$shell->run();

You will find shell directory in magento root. place this file in shell directory.

Add add file in crontab via cpanel or run via ssh.

php /chroot/home/mydomain/shell/whateverfilename.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.