Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
A node command runs manually but crontab crashes

I have a discord bot that I made and I used to use crontab to have it just restart and update the bot automatically each day at 2 am. At some point recently it stopped working but I don't know why. The script is the following:

#!/usr/bin/bash
echo "Killing application..."
pkill -9 node
echo "Moving to bot dir..."
cd /home/pi/theBot/
git pull
npm install
echo "Starting bot..."
node /home/pi/theBot/bot.js

When I run this manually it works just fine and starts up perfect. When it runs through crontab however, it gets errors presumably related to optional chaining in my node project; it cites a line that goes:

if(msg.mentions?.users?.size > 0) {

I normally run node v14.17.6 but I installed and am using v16.13.0 and npm v8.1.0.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!