System Administration Guide: Basic Administration

ProcedureHow to Change an Environment Variable for a Service

This procedure shows how to modify cron environment variables to help with debugging.

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Verify that the service is running.

    # svcs system/cron
    STATE          STIME    FMRI
    online         Dec_04   svc:/system/cron:default
  3. Set environment variables.

    In this example the UMEM_DEBUG and LD_PRELOAD environment variables are set. For information about the setenv subcommand refer to the svccfg(1M) man page.

    # svccfg -s system/cron:default setenv UMEM_DEBUG default
    # svccfg -s system/cron:default setenv LD_PRELOAD
  4. Refresh and restart the service.

    # svcadm refresh system/cron
    # svcadm restart system/cron
  5. Verify that the change has been made.

    # pargs -e `pgrep -f /usr/sbin/cron`
    100657: /usr/sbin/cron
    envp[0]: LOGNAME=root
    envp[2]: PATH=/usr/sbin:/usr/bin
    envp[3]: SMF_FMRI=svc:/system/cron:default
    envp[4]: SMF_METHOD=/lib/svc/method/svc-cron
    envp[5]: SMF_RESTARTER=svc:/system/svc/restarter:default
    envp[6]: TZ=GB
    envp[7]: UMEM_DEBUG=default