Синтаксис Crontab / bin / sh [дубликат]

Prueba esto:

lspci -nn  | grep -oP 'VGA.*NVIDIA.*\[\K[\w:]+'

o más portátil (algunos sistemas operativos Linux antiguos no tienen el interruptor -P)

lspci -nn  | perl -lne 'print $& if /VGA.*NVIDIA.*\[\K[\w:]+/'

Salida:

10de:1c81

LiveDemo con explicaciones a la derecha

-1
06.04.2018, 10:59
2 ответа

У меня нет точных сведений об ошибках, которые вы получаете, но я предполагаю, что это проблема с экранированными символами (вы используете прямую косую черту, а не обратную косую черту для даты)

The "sixth" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (), will be changed into newline charac- ters, and all data after the first % will be sent to the command as standard input.

Попробуйте еще этот формат

`date +\%Y\%m\%d\`
4
28.04.2021, 23:48

Решение 1:Поместите обратную косую черту \сdate

2,17,32,47 * * * * tar -czvf /opt/SOMEFILES >> /var/lib/`date +\%Y\%m\%d\`

Решение 2:

Вы также можете поместить свои команды в файл оболочки, а затем выполнить файл оболочки с помощью cron.

job.sh

 tar -czvf /opt/SOMEFILES >> /var/lib/`date +\%Y\%m\%d\` 

хрон

2,17,32,47 * * * * jobs.sh
2
28.04.2021, 23:48

Теги

Похожие вопросы