Run cron job entries with full root user's profile

Aruba Employee
Aruba Employee


Cron jobs do not run with the bashrc profile loaded. AMP relies on the .bashrc file to initiate many environment variables and provide aliased functions. Without these variables or aliases, cron entries can fail to run if you try to use something that is not defined.


You can initialize the bashrc profile inside a cron job. To do this, follow the format below:

* * * * * /bin/bash -c '. /root/.bashrc && <CMD>'


A common problem with cron is not having aliased commands such as "s2w". Also, the SNMP MIBs can not be translated in a cron job because the environment variables for the MIBs directory hasn't been initialized. By referencing the bashrc profile, these problems go away. The following cron entry would poll a controller for a specific OID every 1 minute. It saves the results to a /tmp file and each poll is preceded with the timestamp of when the command ran.

* * * * * /bin/bash -c '. /root/.bashrc && (date && s2w public wlanAPChUtilization -OX) >> /tmp/ap_ch_data.txt'

Version history
Revision #:
1 of 1
Last update:
‎06-29-2014 09:58 AM
Updated by:
Labels (1)
Search Airheads
Showing results for 
Search instead for 
Did you mean: