我想让cron运行一个jar文件。键入命令时,它将按预期工作:
root@ubuntu:~/AndKnucklesBot# cd /root/AndKnucklesBot; java -jar AndKnucklesBot.jar /root/knuxSecrets.txt
The Art of Interior Decoration & Knuckles
但是,当我使用以下行设置cron时(出于调试目的,每分钟运行一次)
* * * * * cd /root/AndKnucklesBot; java -jar AndKnucklesBot.jar /root/knuxSecrets.txt
我收到以下错误电子邮件:
From root@ubuntu.members.linode.com Mon Sep 4 07:37:01 2017
Return-Path: <root@ubuntu.members.linode.com>
X-Original-To: root
Delivered-To: root@ubuntu.members.linode.com
Received: by ubuntu.members.linode.com (Postfix, from userid 0)
id 9ACA866BE; Mon, 4 Sep 2017 07:37:01 +0000 (UTC)
From: root@ubuntu.members.linode.com (Cron Daemon)
To: root@ubuntu.members.linode.com
Subject: Cron <root@ubuntu> cd /root/AndKnucklesBot; java -jar AndKnucklesBot.jar /root/knuxSecrets.txt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20170904073701.9ACA866BE@ubuntu.members.linode.com>
Date: Mon, 4 Sep 2017 07:37:01 +0000 (UTC)
/root/knuxSecrets.txt
我暗自怀疑这与我在根目录下有这些文件有关,而cron或java运行时没有运行它们的权限。不过,我对这件事还不够熟悉,无法确定问题所在。提前谢谢。
更新:有人要求加入 sudo file /var/spool/cron/crontabs/root
所以这里是:
/var/spool/cron/crontabs/root: ASCII text, with CRLF, LF line terminators
暂无答案!
目前还没有任何答案,快来回答吧!