Solved /etc/periodic.conf: /root: Permission denied

I keep getting the e-mail from one of my big file servers which reads

Code:
/etc/periodic.conf: /root: Permission denied

That is not good as there is whole bunch of periodic scripts which I need running. Since periodic is called from cron my first hunch was to check
.cshrc since crontab is using relative paths.

Code:
# $FreeBSD: releng/10.1/etc/root/dot.cshrc 243893 2012-12-05 13:56:39Z eadler $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
# more examples available at /usr/share/examples/csh/
#

alias h  history 25
alias j  jobs -l
alias la  ls -aF
alias lf  ls -FA
alias ll  ls -lAF

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER  more
setenv  BLOCKSIZE  K

if ($?prompt) then
  # An interactive shell -- set some stuff up
  set prompt = "%N@%m:%~ %# "
  set promptchars = "%#"

  set filec
  set history = 1000
  set savehist = (1000 merge)
  set autolist = ambiguous
  # Use history to aid expansion
  set autoexpand
  set autorehash
  set mail = (/var/mail/$USER)
  if ( $?tcsh ) then
  bindkey "^W" backward-delete-word
  bindkey -k up history-search-backward
  bindkey -k down history-search-forward
  endif

endif

This is the crontab permission and file

Code:
root@uranus:~ # ls -l -d /etc/crontab
-rw-r--r--  1 root  wheel  670 May 14  2015 /etc/crontab

Code:
root@uranus:~ # more /etc/crontab
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD$
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour  mday  month  wday  who  command
#
*/5  *  *  *  *  root  /usr/libexec/atrun
#
# Save some entropy so that /dev/random can re-seed on boot.
*/11  *  *  *  *  operator /usr/libexec/save-entropy
#
# Rotate log files every hour, if necessary.
0  *  *  *  *  root  newsyslog
#
# Perform daily/weekly/monthly maintenance.
1  3  *  *  *  root  periodic daily
15  4  *  *  6  root  periodic weekly
30  5  1  *  *  root  periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,31  0-5  *  *  *  root  adjkerntz -a

Finally this is my periodic.conf file


Code:
root@uranus:~ # ls -l /etc/periodic.conf
-rw-r--r--  1 root  wheel  747 Oct 31 10:05 /etc/periodic.conf


Code:
#!/bin/sh
# Predrag Punosevac options

daily_status_zfs_enable="YES"  # Check ZFS
daily_status_zfs_zpool_list_enable="YES"
daily_status_ntpd_enable="YES"  # Check NTP status

# 800.scrub-zfs
daily_scrub_zfs_enable="YES"
daily_scrub_zfs_pools=""  # empty string selects all pools
daily_scrub_zfs_default_threshold="15"  # days between scrubs

daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"

daily_status_security_enable="NO"

daily_show_success="NO"
daily_show_info="NO"
daily_show_badconfig="NO"

weekly_show_success="NO"
weekly_show_info="NO"
weekly_show_badconfig="NO"

monthly_show_success="NO"
monthly_show_info="NO"
monthly_show_badconfig="NO"
~


Any hints what am I doing wrong?
 
Anything in /var/log/cron that might indicate what's wrong?

Note, cron(8) doesn't use or care about root's .cshrc.
 
  • Thanks
Reactions: Oko
Code:
Feb 15 10:10:00 uranus /usr/sbin/cron[63496]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:11:00 uranus /usr/sbin/cron[63504]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 10:15:00 uranus /usr/sbin/cron[63567]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:20:00 uranus /usr/sbin/cron[63599]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:22:00 uranus /usr/sbin/cron[63613]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 10:25:00 uranus /usr/sbin/cron[63643]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:30:00 uranus /usr/sbin/cron[63688]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:33:00 uranus /usr/sbin/cron[63708]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 10:35:00 uranus /usr/sbin/cron[63732]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:40:00 uranus /usr/sbin/cron[63763]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:44:00 uranus /usr/sbin/cron[63788]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 10:45:00 uranus /usr/sbin/cron[63806]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:50:00 uranus /usr/sbin/cron[63838]: (root) CMD (/usr/libexec/atrun)
Feb 15 10:55:00 uranus /usr/sbin/cron[63870]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 10:55:00 uranus /usr/sbin/cron[63871]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:00:00 uranus /usr/sbin/cron[63914]: (root) CMD (newsyslog)
Feb 15 11:00:00 uranus /usr/sbin/cron[63915]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:00:00 uranus /usr/sbin/cron[63916]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:05:00 uranus /usr/sbin/cron[64040]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:10:00 uranus /usr/sbin/cron[64072]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:11:00 uranus /usr/sbin/cron[64080]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:15:00 uranus /usr/sbin/cron[64131]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:20:00 uranus /usr/sbin/cron[64162]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:22:00 uranus /usr/sbin/cron[64176]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:25:00 uranus /usr/sbin/cron[64205]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:30:00 uranus /usr/sbin/cron[64237]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:33:00 uranus /usr/sbin/cron[64256]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:35:00 uranus /usr/sbin/cron[64280]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:40:00 uranus /usr/sbin/cron[64311]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:44:00 uranus /usr/sbin/cron[64337]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:45:00 uranus /usr/sbin/cron[64355]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:50:00 uranus /usr/sbin/cron[64386]: (root) CMD (/usr/libexec/atrun)
Feb 15 11:55:00 uranus /usr/sbin/cron[64418]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 11:55:00 uranus /usr/sbin/cron[64419]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:00:00 uranus /usr/sbin/cron[64463]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 12:00:00 uranus /usr/sbin/cron[64464]: (root) CMD (newsyslog)
Feb 15 12:00:00 uranus /usr/sbin/cron[64465]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:05:00 uranus /usr/sbin/cron[64548]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:10:00 uranus /usr/sbin/cron[64587]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:11:00 uranus /usr/sbin/cron[64595]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 12:15:00 uranus /usr/sbin/cron[64648]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:20:00 uranus /usr/sbin/cron[64683]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:22:00 uranus /usr/sbin/cron[64697]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 12:25:00 uranus /usr/sbin/cron[64727]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:30:00 uranus /usr/sbin/cron[64758]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:33:00 uranus /usr/sbin/cron[64778]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 12:35:00 uranus /usr/sbin/cron[64801]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:40:00 uranus /usr/sbin/cron[64833]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:44:00 uranus /usr/sbin/cron[64858]: (operator) CMD (/usr/libexec/save-entropy)
Feb 15 12:45:00 uranus /usr/sbin/cron[64876]: (root) CMD (/usr/libexec/atrun)
Feb 15 12:50:00 uranus /usr/sbin/cron[64908]: (root) CMD (/usr/libexec/atrun)
 
At least that shows that cron(8) is running normally. So it's probably an error in one of the periodic scripts (or one of them is chocking on a setting).
 
That message is displayed when you try to run a script which does not have the x permission set...is the x bit set on all the scripts that get run?
ie ls -l /etc/periodic/*
 
  • Thanks
Reactions: Oko
Looks good to me


Code:
root@uranus:~ # ls -l /etc/periodic/*
/etc/periodic/daily:
total 126
-rwxr-xr-x  1 root  wheel  1202 May 14  2015 100.clean-disks
-rwxr-xr-x  1 root  wheel  1492 May 14  2015 110.clean-tmps
-rwxr-xr-x  1 root  wheel  1012 May 14  2015 120.clean-preserve
-rwxr-xr-x  1 root  wheel  619 May 14  2015 130.clean-msgs
-rwxr-xr-x  1 root  wheel  980 May 14  2015 140.clean-rwho
-rwxr-xr-x  1 root  wheel  505 May 14  2015 150.clean-hoststat
-rwxr-xr-x  1 root  wheel  1664 May 14  2015 200.backup-passwd
-rwxr-xr-x  1 root  wheel  916 May 14  2015 210.backup-aliases
-rwxr-xr-x  1 root  wheel  605 May 14  2015 300.calendar
-rwxr-xr-x  1 root  wheel  1387 May 14  2015 310.accounting
-rwxr-xr-x  1 root  wheel  640 May 14  2015 330.news
-rwxr-xr-x  1 root  wheel  545 May 14  2015 400.status-disks
-rwxr-xr-x  1 root  wheel  492 May 14  2015 401.status-graid
-rwxr-xr-x  1 root  wheel  718 May 14  2015 404.status-zfs
-rwxr-xr-x  1 root  wheel  501 May 14  2015 406.status-gmirror
-rwxr-xr-x  1 root  wheel  497 May 14  2015 407.status-graid3
-rwxr-xr-x  1 root  wheel  495 May 14  2015 408.status-gstripe
-rwxr-xr-x  1 root  wheel  495 May 14  2015 409.status-gconcat
-rwxr-xr-x  1 root  wheel  518 Aug 25 13:38 420.status-network
-rwxr-xr-x  1 root  wheel  610 May 14  2015 430.status-rwho
-rwxr-xr-x  1 root  wheel  1348 May 14  2015 440.status-mailq
-rwxr-xr-x  1 root  wheel  694 May 14  2015 450.status-security
-rwxr-xr-x  1 root  wheel  1901 May 14  2015 460.status-mail-rejects
-rwxr-xr-x  1 root  wheel  407 May 14  2015 480.status-ntpd
-rwxr-xr-x  1 root  wheel  646 May 14  2015 500.queuerun
-rwxr-xr-x  1 root  wheel  747 Aug 25 13:38 510.status-world-kernel
-rwxr-xr-x  1 root  wheel  2394 May 14  2015 800.scrub-zfs
-rwxr-xr-x  1 root  wheel  641 May 14  2015 999.local

/etc/periodic/monthly:
total 14
-rwxr-xr-x  1 root  wheel  858 May 14  2015 200.accounting
-rwxr-xr-x  1 root  wheel  704 May 14  2015 450.status-security
-rwxr-xr-x  1 root  wheel  533 May 14  2015 999.local

/etc/periodic/security:
total 68
-rwxr-xr-x  1 root  wheel  2037 May 14  2015 100.chksetuid
-rwxr-xr-x  1 root  wheel  2057 May 14  2015 110.neggrpperm
-rwxr-xr-x  1 root  wheel  2232 May 14  2015 200.chkmounts
-rwxr-xr-x  1 root  wheel  1878 May 14  2015 300.chkuid0
-rwxr-xr-x  1 root  wheel  1871 May 14  2015 400.passwdless
-rwxr-xr-x  1 root  wheel  1875 May 14  2015 410.logincheck
-rwxr-xr-x  1 root  wheel  1909 May 14  2015 500.ipfwdenied
-rwxr-xr-x  1 root  wheel  1890 May 14  2015 510.ipfdenied
-rwxr-xr-x  1 root  wheel  1949 May 14  2015 520.pfdenied
-rwxr-xr-x  1 root  wheel  2155 May 14  2015 550.ipfwlimit
-rwxr-xr-x  1 root  wheel  1918 May 14  2015 610.ipf6denied
-rwxr-xr-x  1 root  wheel  1839 May 14  2015 700.kernelmsg
-rwxr-xr-x  1 root  wheel  2255 May 14  2015 800.loginfail
-rwxr-xr-x  1 root  wheel  2226 May 14  2015 900.tcpwrap
-rwxr-xr-x  1 root  wheel  2705 May 14  2015 security.functions

/etc/periodic/weekly:
total 27
-rwxr-xr-x  1 root  wheel  548 May 14  2015 310.locate
-rwxr-xr-x  1 root  wheel  937 May 14  2015 320.whatis
-rwxr-xr-x  1 root  wheel  1082 May 14  2015 330.catman
-rwxr-xr-x  1 root  wheel  550 May 14  2015 340.noid
-rwxr-xr-x  1 root  wheel  699 May 14  2015 450.status-security
-rwxr-xr-x  1 root  wheel  532 May 14  2015 999.local
 
Um, the other low-hanging fruit would be to check root's mail. cron outputs the stdout of whatever it runs as a message.
 
I keep getting the e-mail from one of my big file servers which reads

Code:
/etc/periodic.conf: /root: Permission denied

[mega-snip]

Any hints what am I doing wrong?
Nothing particularly stands out, but couple things seem odd to me:

1) Your /etc/crontab has an unsubstituted $FreeBSD$ ident. Where did this file come from? It looks like the contents are correct, but it doesn't look like any "out-of-the-box" /etc/crontab I've seen.
2) You have a hashbang at the top of your /etc/periodic.conf. I've never used that, I've just put the
Code:
foo_enable="YES"
lines in there. Again, I don't think that should matter, but...

To track this down, you should be able to do the following:
Code:
su
cd /somewhere-with-lots-of-disk-space
ktrace -di periodic daily (or weekly, or monthly - whichever one is having the problems)
[wait for the error or completion]
kdump | more
/Permission
[now use b to back up a screen or two, to see what it was doing when it got the Permission denied error]
Don't forget to remove the ktrace.out file when you're done. It can be quite large.

Also, be aware that the above may execute some of the periodic tasks before it bombs out. So if you do billing, snapshot removal, etc. in your periodic job, some / all of that may happen as part of this diagnosis, at an unexpected time. Looking at your periodic.conf, the only thing that seems like it might be a problem is the daily scrub. An additional scrub is probably just a nuisance, though. Mostly I added this in case someone finds this topic in the future and tries my suggestion.
 
There's a lonely tilde in the first post after the CODE end tag of periodic.conf.

Code:
monthly_show_success="NO"
monthly_show_info="NO"
monthly_show_badconfig=&quot;NO&quot;</pre></div><br />
~<br />
<br />
<br />

Juha
 
  • Thanks
Reactions: Oko
Check the last lines of your configuration files, depending on the editor you use you might not spot a spurious extra tilde on the last line.
 
  • Thanks
Reactions: Oko
There's a lonely tilde in the first post after the CODE end tag of periodic.conf.

Code:
monthly_show_success=&quot;NO&quot;
monthly_show_info=&quot;NO&quot;
monthly_show_badconfig=&quot;NO&quot;</pre></div><br />
~<br />
<br />
<br />

Juha
Nailed!!! I am using nvi of course which uses ~ for empty lines so it is difficult to catch mistake like that. I was even in "list" mode but I typically don't look beyond the last line. I will see tomorrow if I still get e-mail with the error in the log file.
 
Another way to debug this (and I'm surprised no one suggested this before) is running the entire kittenkaboodle with sh -x. This would have told you where the error is.

The periodic(8) command is just a shell script itself which sources the config file (with .), and then does just a for loop over all the /etc/periodic files and runs them as $file. So you could have:

- Used sh -x /usr/sbin/periodic weekly and see if that showed up anything
- If that didn't show the error (and in this case, it would), you could have modified this script to use sh -x $file.
 
Last edited by a moderator:
Back
Top