Executing cron tasks manually in Magento

For example, we have this cron task on a config.xml file of a specific module:

<catgento_sap_sync_nonimages><schedule><cron_expr>*/15 * * * *</cron_expr></schedule><run><model>sap/cron_sync_nonimages::run</model></run></catgento_sap_sync_nonimages>

we can create a new script that loads and executes that cron task like this (create a script.php file and put something like this inside):

//Load Magento API
//First we load the model
$model= Mage::getModel('sap/cron_sync_nonimage');
//Then execute the task

The last step would be running this script manually (php script.php).

magento 1 create admin user programmatically

    $mageFilename = 'app/Mage.php';
    if (!file_exists($mageFilename)) {
        echo $mageFilename." was not found";
    require_once $mageFilename;

    try {
        //create new user by providing details below
        $user = Mage::getModel('admin/user')
                'username'  => 'admin1',
                'firstname' => 'John',
                'lastname'  => 'Doe',
                'email'     => 'john@example.com',
                'password'  => 'welcome123',
                'is_active' => 1

    } catch (Exception $e) {
        echo $e->getMessage();

    try {
        //create new role
        $role = Mage::getModel("admin/roles")

        //give "all" privileges to role

    } catch (Mage_Core_Exception $e) {
        echo $e->getMessage();
    } catch (Exception $e) {
        echo 'Error while saving role.';

    try {
        //assign user to role

    } catch (Exception $e) {
        echo $e->getMessage();

    echo 'Admin User sucessfully created!';

Magento 2 useful commands

update DB command

 sudo php -d memory_limit=-1 bin/magento setup:upgrade
 sudo php -d memory_limit=-1  bin/magento setup:db-schema:upgrade 

//deploy static content

sudo php -d memory_limit=-1 bin/magento setup:static-content:deploy -f

// change permissions

sudo chmod -R 777 var pub 

//deply setup content

sudo php -d memory_limit=-1 bin/magento setup:di:compile

//enable/disable module

sudo bin/magento module:disable --clear-static-content Component_Name