1

I'd like to make sure that every user specific crontab has the same PATH-environment. I tried to set the PATH in /etc/crontab but it seems like this config file is not read by crond.

Following are the cron related packages that are installed on my machine:

root@machine:~> rpm -qa | grep cron
cronolog-1.6.2-10.el6.x86_64
cronie-anacron-1.4.4-7.el6.x86_64
cronie-noanacron-1.4.4-7.el6.x86_64
crontabs-1.10-33.el6.noarch
cronie-1.4.4-7.el6.x86_64

UPDATE: my /etc/crontab

sorry for the late reply.

SHELL=/bin/bash
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
1
  • Christian, please merge your accounts by following the procedure here – you need to log in with your old credentials to be able to edit the question, add comments, etc. Thanks.
    – slhck
    Jul 12, 2013 at 8:56

1 Answer 1

0

Are you sure you are setting the $PATH correctly? Have a look at man 5 crontab:

An  active  line in a crontab will be either an environment setting or a cron com‐
mand.  The crontab file is parsed from top to bottom, so any environment  settings
will affect only the cron commands below them in the file.  An environment setting
is of the form,

    name = value

where the spaces around the equal-sign (=) are optional, and any  subsequent  non-
leading  spaces  in  value  will be part of the value assigned to name.  The value
string may be placed in quotes (single or double, but matching) to preserve  lead‐
ing  or  trailing  blanks.  To  define an empty variable, quotes must be used. The
value string is not parsed for environmental substitutions or replacement of vari‐
ables, thus lines like

    PATH = $HOME/bin:$PATH

will not work as you might expect. And neither will this work

    A=1
    B=2
    C=$A $B
There will not be any subsitution for the defined variables in the last value.

An alternative for setting up the commands path is using the fact that many shells
will treat the tilde(~) as substitution of $HOME, so if  you  use  bash  for  your
tasks you can use this:

     SHELL=/bin/bash
     PATH=~/bin:/usr/bin/:/bin
6
  • Hi terdon, thanks for your reply. There are no variables in my PATH definition. I already tried to put the string in quotes, but it's not working either.
    – john.dough
    Jun 25, 2013 at 6:19
  • @christian strange. Could you post the /etc/crontab that is ignored?
    – terdon
    Jun 25, 2013 at 12:57
  • @christian never post updates as comments, they are impossible to read and get lost in the clutter. Edit your original question instead.
    – terdon
    Jul 1, 2013 at 14:27
  • Any further tips for this issue? You can see the ignored crontab in my initial post as an update.
    – john.dough
    Jul 12, 2013 at 14:16
  • @christian /etc/crontab is not a configuration file, it is the system-wide crontab. So any settings set there will not be inherited by the user specific crontabs. Not a bug but a feature in other words. Sorry, I don't know how to set a system wide cronpath other than setting a system wide path.
    – terdon
    Jul 12, 2013 at 14:33

You must log in to answer this question.

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