0

0 8 * * * /usr/local/bin/npm --prefix /root/myscript run start > /root/logs

I can see at the log file that this script STARTS execution at 8am.

Although, if the script does exceed more than 60 seconds running: it stops.

I know it has nothing to do with the script because it has proper error handling that would get outputted to logs: which is not the case.

The script simply stops at 8:01am.

It seems like crontab stops it, just like when we hit CTRL+C.

8
  • 1
    I'd check the system log or cron's journal (journalctl) for relevant messages. Does npm have a verbose option? If yes, use it. Aug 28, 2021 at 5:59
  • Maybe it takes 1 minute to figure out there's nothing to be done. Aug 28, 2021 at 6:52
  • It's usually a lack of environment variables… try env -i /usr/local/bin/npm … from the shell, that might help narrowing it down. Aug 28, 2021 at 7:54
  • As @UlrichSchwarz says. In particular, cron does not work as a login would -- it does not read your .profiles. Aug 28, 2021 at 8:14
  • it's not about environment variables. If the node script doesn't hang for more than 1 minute, then it executes till the end. Aug 28, 2021 at 11:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.