0

I'm hosting a discord bot on my raspberry pi and I want it to create new session on start up

I have tried with edit rc.local :

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  /usr/bin/tmux new-session -d "cd /home/pi/myBot; sudo node index.js"
fi

exit 0

However it didn't work, when I check with tmux a, it said no sessions

Any help would be much appreciated!

4
  • Does this answer your question? Execute script on start-up Apr 22 '20 at 9:00
  • @DmitryGrigoryev I tried it and it didn't work either, the service said it's running but the bot didn't Apr 22 '20 at 15:51
  • I assume that it doesn't recognize ether tmux nor node, I even tried with full path /usr/bin/tmux and /usr/bin/node Apr 22 '20 at 15:58
  • Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. Does the command run from the commandline successfully? Does it has any output on the console or graphical?
    – Ingo
    Apr 23 '20 at 8:08

Your Answer

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

Browse other questions tagged or ask your own question.