crontab不能自動刪除歸檔日誌

parknkjun發表於2015-07-16
某客戶一套資料庫歸檔太多撐滿磁碟,於是決定使用指令碼自動刪除歸檔,保留15天,指令碼執行沒有任何問題
但是放在crontab裡就是執行不成功,log也沒有產生,查不到原因,後來發現crontab執行完會自動發資訊到mail裡面
於是在/var/spool/mail/路徑下找到oracle檔案:
[oracle@jzh5 2015_07_15]$ cd /var/spool/mail/
[oracle@jzh5 mail]$ ls
oracle  root  rpc
[oracle@jzh5 mail]$ vi oracle 
/bin/sh: /home/oracle/delete_arc.sh: Permission denied
From oracle@jzh5.oracle.com  Wed Jul 15 15:19:01 2015
Return-Path:
Received: from jzh5.oracle.com (localhost.localdomain [127.0.0.1])
        by jzh5.oracle.com (8.13.8/8.13.8) with ESMTP id t6F7I1nS004101
        for ; Wed, 15 Jul 2015 15:19:01 +0800
Received: (from oracle@localhost)
        by jzh5.oracle.com (8.13.8/8.13.8/Submit) id t6F7I1Lr004098;
        Wed, 15 Jul 2015 15:18:01 +0800
Date: Wed, 15 Jul 2015 15:18:01 +0800
Message-Id: <201507150718.t6F7I1Lr004098@jzh5.oracle.com>
From: root@jzh5.oracle.com (Cron Daemon)
To: oracle@jzh5.oracle.com
Subject: Cron /home/oracle/delete_arc.sh
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
/bin/sh: /home/oracle/delete_arc.sh: Permission denied
From oracle@jzh5.oracle.com  Wed Jul 15 15:21:01 2015
Return-Path:
Received: from jzh5.oracle.com (localhost.localdomain [127.0.0.1])
        by jzh5.oracle.com (8.13.8/8.13.8) with ESMTP id t6F7K1iE004121
        for ; Wed, 15 Jul 2015 15:21:01 +0800
Received: (from oracle@localhost)
        by jzh5.oracle.com (8.13.8/8.13.8/Submit) id t6F7K1Aa004118;
        Wed, 15 Jul 2015 15:20:01 +0800
Date: Wed, 15 Jul 2015 15:20:01 +0800
Message-Id: <201507150720.t6F7K1Aa004118@jzh5.oracle.com>
From: root@jzh5.oracle.com (Cron Daemon)
To: oracle@jzh5.oracle.com
Subject: Cron /home/oracle/delete_arc.sh
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
/bin/sh: /home/oracle/delete_arc.sh: Permission denied

原來是delete_arc.sh指令碼沒有許可權,修改許可權[oracle@jzh5 ~]$ chmod 775 delete_arc.sh 後就OK了。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10271187/viewspace-1734629/,如需轉載,請註明出處,否則將追究法律責任。

相關文章