mac中crontab任务不执行
目录
可以查看/var/mail/<username>
中的日志来解决问题。
From zhangrui@zhangruideMacBook-Pro.local Mon Dec 4 16:00:01 2023
Return-Path: <zhangrui@zhangruideMacBook-Pro.local>
X-Original-To: zhangrui
Delivered-To: zhangrui@zhangruideMacBook-Pro.local
Received: by zhangruideMacBook-Pro.local (Postfix, from userid 501)
id 38CB2A7F882E; Mon, 4 Dec 2023 16:00:00 +0800 (CST)
From: zhangrui@zhangruideMacBook-Pro.local (Cron Daemon)
To: zhangrui@zhangruideMacBook-Pro.local
Subject: Cron <zhangrui@zhangruideMacBook-Pro> cd /Users/zhangrui/myobsidian && bash ./obsidian/backup.sh >> obsidian/run.log 2>&1
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=zhangrui>
X-Cron-Env: <USER=zhangrui>
Message-Id: <20231204080001.38CB2A7F882E@zhangruideMacBook-Pro.local>
Date: Mon, 4 Dec 2023 16:00:00 +0800 (CST)
/bin/sh: obsidian/run.log: Operation not permitted
最终这个Operation not permitted的原因是没有授予cron完全的磁盘访问权限。