Sunday, 19 July 2020

Help with Nodejs script in Cronjob

RaspberryPi 4 2GB RAM running Rasbian 10. I use this RPi to perform all my cronjobs and is its main function.The following work at the command line:/usr/bin/node /usr/local/bin/cpanelpuppetbackup/cpanel_pi.js/bin/sh /usr/local/bin/cpanelpuppetbackup/cpanel_pi.shThe following doesn't work in cron:29 7 * * * /bin/sh /usr/local/bin/cpanelpuppetbackup/cpanel_pi.sh33 7 * * * /usr/bin/node /usr/local/bin/cpanelpuppetbackup/cpanel_pi.js15 17 * * * cd /usr/local/bin/cpanelpuppetbackup/ && node cpanel_pi.jsAll my other cronjobs are working as expected which are all .sh scripts. As you can see from above, I have tried to wrap the node command in a shell script. That works, just not in a cronjob.I've also included #!/usr/local/bin/node at the beginning of my .js script with no change.I've confirmed that the which command produces /usr/bin/node for node.When I view top at the expected time, I do see node appear for a split second, but my script doesn't produce the results.I've been looking at node-cron, but I'm a little confused. Do I add my entire script within the cron-schedule function like this:cron.schedule('* * * * *', () => {<<< all code goes here? >>>});Any help would be appreciated.

Submitted July 19, 2020 at 11:35PM by cinemafunk

No comments:

Post a Comment