Put it in a wrapper script that calls the service.
e.g. If you run a command to start a service named "myservice" but want to set variable called OUTPUTDIR you'd create a simple script that does it:Z
Code:
!/bin/bash
export OUTPUTDIR=<value>
myservice
Alternatively if this is a cron job you could just create the script with the above export and call it before the service in crontab:
Script "myenv.sh"
Code:
!/bin/bash
export OUTPUTDIR=<value>
cron entry (in the crontab of the user you want this run as):
Code:
* * * * * . /<pathto>/myenv.sh ; /<pathto>/myservice
Note that the cron entry "sources" myenv.sh rather than simply executing it.