[gelöst] string in crontab

Vom einfachen Programm zum fertigen Debian-Paket, Fragen rund um Programmiersprachen, Scripting und Lizenzierung.
Antworten
pcace
Beiträge: 231
Registriert: 28.08.2011 01:08:55

[gelöst] string in crontab

Beitrag von pcace » 18.08.2022 11:43:15

Hi,

kurze Frage das hier funktioniert in der bash:

Code: Alles auswählen

 /usr/local/bin/cntb update snapshot 100071442 snap1660120090 --name 'daily_updated_'$(date +%Y-%m-%d-%T)
als cronjob nicht:

Code: Alles auswählen

* * */1 * * /usr/local/bin/cntb update snapshot 100071442 snap1660120090 --name 'daily_updated_'$(date +%Y-%m-%d-%T)
das problem ist das nach . irgendwie scheint das nicht als String durchzugehen:

Code: Alles auswählen

Subject: Cron <root@mail> /usr/local/bin/cntb update snapshot 100071442 snap1660120090 --name 'daily_updated_'$(date +
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: <20220818093501.DB1342E0577@fwd.mail.johannes-froelich.de>
Date: Thu, 18 Aug 2022 11:35:01 +0200 (CEST)

/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")
was mache ich falsch?!

Gruß und Dank!
Zuletzt geändert von pcace am 12.09.2022 10:13:17, insgesamt 1-mal geändert.

JTH
Moderator
Beiträge: 3014
Registriert: 13.08.2008 17:01:41
Wohnort: Berlin

Re: string in crontab

Beitrag von JTH » 18.08.2022 11:52:32

Die % müssen escapet werden:
https://manpages.debian.org/cron/crontab.5 hat geschrieben: Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
Manchmal bekannt als Just (another) Terminal Hacker.

pcace
Beiträge: 231
Registriert: 28.08.2011 01:08:55

Re: string in crontab

Beitrag von pcace » 12.09.2022 10:12:54

top vielen Dank!!!!

Antworten