cron não está executando o script

1

Sou novato no Linux, então peço desculpas por talvez uma pergunta boba. O problema é que estou tentando realizar uma execução de trabalho automaticamente a cada 20 minutos a cada hora.

  1. Eu crio um arquivo sh na minha pasta de scripts:

.#!/bin/sh cd /home/ubuntu/scripts/dm-customer &&
python3 ./md_executor.py

1.1 Eu transformo o arquivo sh como executável:

  • chmod 755 etl-execution.sh
  • chmod + x etl-execution.sh

    1. Agora eu digitei crontab -e e adicione uma linha:

      • 55 * * * * ubuntu /home/ubuntu/scripts/dm-customer/etl-execution.sh

Então meu cron deve ser acionado automaticamente, mas nada está acontecendo. Eu tentei:

  • Edite meu crontab -e usando ubuntu em vez de root , mas nada acontece
  • Se eu executo manualmente o sh na minha sessão do ubuntu atravessa realmente não entendo.

Agradeço qualquer feedback que esteja me deixando louco. obrigado

    
por Andres Angel 20.04.2018 / 17:02

1 resposta

2
55 * * * * ubuntu /home/ubuntu/scripts/dm-customer/etl-execution.sh

Por que você tem o Ubuntu?

O formato é, de man 5 crontab :

   The format of a cron command is similar to the V7 standard, with a num-
   ber  of upward-compatible extensions.  Each line has five time-and-date
   fields followed by a username (if this is the system crontab file), and
   followed  by  a  command.   Commands  are  executed by cron(8) when the
   'minute', 'hour', and 'month of the  year'  fields  match  the  current
   time, and at least one of the two 'day' fields ('day of month', or 'day
   of week') match the current time (see "Note" below).

O nome de usuário só será incluído se for o crontab do sistema. Se você estiver executando crontab -e como seu próprio usuário, ele deverá não ser incluído.

Tente

55 * * * * /home/ubuntu/scripts/dm-customer/etl-execution.sh

e veja se isso funciona.

    
por vidarlo 20.04.2018 / 17:11