Tuesday 21 September 2010

How to execute a script in FreeNAS

Using Script in Freenas consists of a few steps:
1. Creating file
2. Apply correct permissions
3. Run script in CLI
4. Run script as a CRON job.

AD.1 How to create the file:
In Advanced|Execute command You type:

CODE: SELECT ALL
touch /mnt/YOUR_MOUNT_NAME/YOUR_SCRIPT_NAME.sh


AD.2 Correct permissions:
In Advanced | Execute command type:

CODE: SELECT ALL
chmod u+x /mnt/YOUR_MOUNT_NAME/YOUR_SCRIPT_NAME.sh


AD.3 Run script from CLI
*********** TO VERIFY ***********

CODE: SELECT ALL
#/bin/sh /mnt/YOUR_MOUNT_NAME/YOUR_SCRIPT_NAME.sh


AD.4 Add script to Cron
In System|Advanced|Cron add new job.
As command put :

CODE: SELECT ALL
/mnt/YOUR_MOUNT_NAME/YOUR_SCRIPT_NAME.sh


UPDATE:
Additionally if Cron failed to run the script you can try;
CODE: SELECT ALL
/bin/bash -x
at the beggining of the script line ie:

CODE: SELECT ALL
/bin/bash -x /mnt/YOUR_MOUNT_NAME/YOUR_SCRIPT_NAME.sh


After running this command You should get: The cron job has been executed successfully.

No comments:

Post a Comment