I am trying to create a cron job which starts my node app every hour, the command that starts is:
node /home/pi/Desktop/DiscordBots/panda-bot/index.js
however this returns:
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open 'warnings.json'
It does start if I cd to the directory first /home/pi/Desktop/DiscordBots/panda-bot
and then node index.js
This would mean I have to create a shell script that cds and then starts node but I prefer to do start it in one line, is this possible?
Cron runs your commands in your home directory. If you want a oneliner command in your crontab then you would have to use &&
In your crontab
0 * * * * cd /home/pi/Desktop/DiscordBots/panda-bot && node index.js
Please refer to :https://unix.stackexchange.com/questions/38951/what-is-the-working-directory-when-cron-executes-a-job