0

I have noticed that scripts which run perfectly from the command line fail to work properly in Anacron. Often the reason is that Anacron requires the full path to the commands. Is there a way to make the $PATH that Anacron uses the same as the $PATH the user or su uses?

1 Answer 1

1

I think this is done just before the commands in the anacrontab according to the man 5 anacrontab pages:

Environment assignment lines are of the form:

     VAR = VALUE

  Spaces around VAR are removed.  No spaces around VALUE are allowed (unless you want them to be part of the  value).
  The  assignment takes effect from the next line to the end of the file, or to the next assignment of the same vari‐
   able.

  Empty lines are either blank lines, line containing white-space only, or lines with white-space followed by  a  '#'
   followed by an arbitrary comment.

  You can continue a line onto the next line by ending it with a '\'.

Have a look in the /etc/anacrontab file:

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1   5   cron.daily  run-parts --report /etc/cron.daily
7   10  cron.weekly run-parts --report /etc/cron.weekly
@monthly    15  cron.monthly    run-parts --report /etc/cron.monthly

As you can see the environmental variables are set before the commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .