2

I want to run all node.js scripts in some folder on startup (in perfect case, running some npm script (I think the thing i run by npm run someScript by this) in all folders in some specific folder). Is this possible without making some Java program? THX

1 Answer 1

2

You can probably use Cron to do that. You can read the documentation here: https://www.raspberrypi.org/documentation/linux/usage/cron.md. You can enter this to edit crontab:

crontab -e

Select Nano or any editor you're comfortable with and add a line like this:

@reboot npm run /home/pi/somescript

I recommend you read the documentation first, though.

9
  • Ok, but my goal is to just put the app in some folder and it will run on reboot without doing anything else. Aug 6, 2020 at 14:43
  • @doc.Chocholoušek That would work too you would just need to replace /home/pi/somescript with the location of your script.
    – aklingam
    Aug 6, 2020 at 15:12
  • Ok, but still I need to write the command to terminal. And by more actions to do, there is bigger chance that I will forget one of them. Aug 6, 2020 at 15:38
  • @doc.Chocholoušek You just need to do this once as long as you don't keep changing the directory or filename of your script.
    – aklingam
    Aug 6, 2020 at 15:40
  • Yes, but by adding more and more apps, I need to write it to console again and again (I need this for discord bots and I am making also really small bots just for fun and I don't want to solve why it isn't working when i forget to start the cron task). Aug 6, 2020 at 15:46

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.