You (oracle) are not allowed to access to (crontab) becaus of pam configuration.

问题描述

现场同事反馈磁盘撑爆,分析发下归档和rman备份目录空间占用最多。

分析过程

oracle用户下查看计划任务时,报错如下:

--查看计划任务
[oracle@crm-ethanDB ~]$ crontab -l
You (oracle) are not allowed to access to (crontab) because of pam configuration.

先前使用过crontab命令配置定期删除归档和rman定时备份的任务,问了下运维同事,最近也没有任何改动。

按照常规流程排查下,顺序如下:

1)查看/bin/crontab的SSID位是否标记S

2)检查/etc/cron* 是否设置了.deny文件限制;

3)检查PAM模块,cat /etc/pam.d/crond,文件中配置是否正常

4)查看系统日志cat /var/log/secure的错误信息

5)查看oracle用户密码过期

查看/bin/crontab的SSID位是否标记S

[root@crm-sbldbdg ~]# ll /bin/crontab
-rwsr-xr-x. 1 root root 57664 Oct 16  2017 /bin/crontab

检查/etc/cron 是否设置了.deny文件限制*

[root@crm-sbldbdg ~]# ll -dl /etc/cron*
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.d
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.daily
-rw-------. 1 root root    0 Oct 16  2017 /etc/cron.deny
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.hourly
drwxr-xr-x. 2 root root 4096 Dec 28  2013 /etc/cron.monthly
-rw-r--r--. 1 root root  451 Dec 28  2013 /etc/crontab
drwxr-xr-x. 2 root root 4096 Dec 28  2013 /etc/cron.weekly

有/etc/cron.deny文件,但没有实际内容,也就不存在什么限制。

注意:

如果存在cron.allow文件,以cron.allow文件优先;如果cron.allow和cron.deny都存在,以cron.allow文件优先;如果只有cron.deny 文件,只能以cron.deny 文件为准。

检查PAM模块,cat /etc/pam.d/crond,文件中配置是否正常

[root@crm-sbldbdg ~]# cat /etc/pam.d/crond
#
# The PAM configuration file for the cron daemon
#
#
# No PAM authentication called, auth modules not needed
account    required   pam_access.so
account    include    password-auth
session    required   pam_loginuid.so
session    include    password-auth
auth       include    password-auth

查看系统日志cat /var/log/secure的错误信息

Mar 3 16:54:01 crm-ethanDB crond[103891]: pam_unix(crond:account): expired password for user oracle (password aged)
Mar 3 16:54:25 crm-ethanDB su: pam_unix(su-l:session): session opened for user root by root2(uid=1001)
Mar 3 16:55:47 crm-ethanDB crontab: pam_unix(crond:account): expired password for user oracle (password aged)

Chage命令查看oracle用户密码有效期

--查看oracle用户密码有效期
[root@crm-sbldbdg ~]# chage -l oracle
Last password change : Aug 31, 2020
Password expires : Feb 27, 2023
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

Password expires : Feb 27, 2023部分,显示oracle的密码到期时间为Feb 27, 2023。

问题原因

oracle账号密码到期,导致oracle下的crontab的定时任务不能正常进行,所以产生如下报错:

[oracle@crm-ethanDB ~]$ crontab -l
You (oracle) are not allowed to access to (crontab) because of pam configuration.

解决办法

修改oracle密码永不过期

--修改oracle密码永不过期
[root@crm-sbldbdg ~]# chage -M 99999 oracle

--chage -l oracle查看命令,再看密码过期时间为never
[root@crm-sbldbdg ~]# chage -l oracle
Last password change : Aug 31, 2020
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 10
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7Minimum number of days between password change : 10
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

经再次验证,oracle下的crontab命令可以正常编辑。

参考链接:排故篇 | You (oracle) are not allowed to access to (crontab) because of pam configuration-CSDN博客

你可能感兴趣的:(oracle,crontab)