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. Commented Aug 28, 2021 at 5:59
  • Maybe it takes 1 minute to figure out there's nothing to be done. Commented 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. Commented 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. Commented 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. Commented Aug 28, 2021 at 11:20

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.