Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

371
Visualizações
How can I run a node script from bash using cron

I have this cron job running on Ubuntu

02 12 * * * quigley-user /mnt/block/alphabits/start.sh >> /mnt/block/alphabits/start.log

The cron job runs on schedule as expected.

I have this snippet in the start.sh script

while read -r ticker apiName ;
   do
      echo "$ticker $apiName"
      sudo /usr/bin/node /mnt/block/alphabits/index.js $ticker $apiName
   done < /mnt/block/alphabits/fmpList.txt

The echo line shows the expected results, however the index.js script does not run. I can't find an error but maybe I'm missing something. If I run the command that's in the cron job from the command line it executes properly

What am I missing? Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is possible your node.js relative import path is missing from crontab context.

And possible other implicit environment variables configurations for node.js

Assuming your user $HOME directory is /home/user1

Suggesting:

Add the following line, into your 2nd line in your start.sh

  #!/bin/bash
  source /home/user1/.bash_profile

This line will add your users' context path and environment variables to your script.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda