1

I have a very simple bash script (run-build.sh):

cd /var/www/project
npm run build

This script works fine when I run it from the command line but I want to run it every 30 minutes via a cron job:

*/30 * * * * /var/www/project/run-build.sh >> /var/www/test.log 2>&1

Which for some reason doesn't work. I have tried various other approaches such as running the cron job as root user or adding the path to node as part of the cron job. However I haven't managed to find a solution yet which is why I am now posting here.

Anyone have any ideas how to get this cron job to work?

0

I updated my cronjob to:

* */12 * * * sudo -u user /var/www/project/run-build.sh >> /var/www/test.log 2>&1

and it now works. I'm sure I tried that before but I must have tried something different.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.