LoginSignup
18
17

More than 5 years have passed since last update.

macで/var/log/cronを記録したい

Posted at

linuxだと普通にログ取られてるのにMacは無効だったので有効化します。

手順

/etc/syslog.conf に以下を追記

/etc/syslog.conf
cron.*      /var/log/cron.log

/System/Library/LaunchDaemons/com.vix.cron.plist 修正
1. ProgramArguments-xmiscを追加
2. StandardErrorPath を追加

/System/Library/LaunchDaemons/com.vix.cron.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.vix.cron</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/sbin/cron</string>
        <string>-x</string>
        <string>misc</string>
    </array>
    <key>KeepAlive</key>
    <dict>
        <key>PathState</key>
        <dict>
            <key>/etc/crontab</key>
            <true/>
        </dict>
    </dict>
    <key>QueueDirectories</key>
    <array>
        <string>/usr/lib/cron/tabs</string>
    </array>
    <key>EnableTransactions</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/var/log/cron.log</string>
</dict>
</plist>

有効化

有効化
$ sudo launchctl
Password:
launchd% unload /System/Library/LaunchDaemons/com.vix.cron.plist 
launchd% load /System/Library/LaunchDaemons/com.vix.cron.plist 

参考

18
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
17