AAA, NAC, Guest Access & BYOD

Run cron job entries with full root user's profile

by on ‎06-29-2014 09:58 AM

PROBLEM :


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.

 SOLUTION :


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

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

EXAMPLE :


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 10.162.108.3 public wlanAPChUtilization -OX) >> /tmp/ap_ch_data.txt'

Search Airheads
Showing results for 
Search instead for 
Did you mean: 
Is this a frequent problem?

Request an official Aruba knowledge base article to be written by our experts.