#reboot via crontab isnt working - linux

IM running a VPS server on Ubuntu 14.04 minimal x86. I connect to it using putty via SSH.
On the server i have a simple script that is starting a few instances of bots
nohup node /nodebots/bot10/server.js &
I use root as a user, so all the privileges and +chmod X are set properly (in my opinion)
The idea is that my node.js program is not excelent + the service im running the bots for sometimes has reboots, server crashes etc.
Ive installed crontab and at this moment struggling to set the script to be run at boot.
Ive used various solutions including trying to boot it via init.d , adding a line to rc.local and well using crontab -e. None of it helps.
Currently the code in crontab looked the following ways
`#reboot sh /nodebots/botsrun.sh`
#reboot root /nodebots/sh botsrun.sh
#reboot cd /nodebots/ && sh botsrun.sh
None of it helped.
Im new to Ubuntu, coding and even terminal commands. I would really apreaciate any kind of help. I will be more then grateful for a step by step tutorial on what im doing wrong and what should be done.

Related

Run mlagents_envs UnityEnvironment from remote ssh login

I have a script in which I build a mlagents_envs.environments.UnityEnvironment that successfully launches and works when I run the script from terminal sessions started on my ubuntu machine (that has a GUI). And if I ssh into the machine, I can run these scripts from tmux sessions that were originally created locally on my machine. If, however, I try to run the script from a terminal session created through the remote ssh connection, the script hangs when trying to create the UnityEnvironment. It just says:
Found path: <path_to_unity_executable>
and eventually times out.
I've tried to run the script with a virtual display and it still doesn't work. Specifically, I've tried:
$ xvfb-run --auto-servernum --server-args='-screen 1 640x480x24:64' python3 python_script.py -batchmode
$ xvfb-run --auto-servernum --server-args='-screen 1 640x480x24:64' python3 python_script.py
And I've tried the instructions found here: https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md
Has anyone encountered this issue? Do you have any suggestions?
The solution ended up being fairly simple. I just needed to specify the right DEVICE before running the script.
$ DEVICE=:1 python3 python_script.py
If anyone else runs into this, you might also need to enable X11 forwarding in both the ssh settings on the server and the client. I'm not 100% sure.

Other ways for auto-start script in Kali Linux?

So I'm basically wanting to get a script to run on system boot. It's basically an SSH callback. I've tried a few ways that I've gotten to work in the past on other distributions, but having a little bit of difficulty here.
First thing I've tried was adding the /path/to/script.rb to /etc/rc.local. However, this file does not exist on the latest version of Kali Linux. I tried to create it and replicate my old Ubuntu rc.local file, but it didn't run on system startup.
Next thing I tried was creating an executable bash script in /etc/init.d/, following the update-rc.d script.sh defaults and making the file executable. Restarted and nothing. If I run the script manually, it works. I tried to redirect the output to a file in the tmp folder, but it doesn't appear that there are any errors from what I'm understanding.
Are there any other ways to get an auto run script started other than these two methods? Seem to be the most common way to get this working, but it's just not doing it for me.
Add script to
/etc/init.d
Run command:
chmod 755 /etc/init.d/script
Run command:
update-rc.d script enable

Raspberry Pi boot script duplicating

I am trying to run a few scripts at each boot of the raspberry pi. I have been able to verify that when they are not configured to start automatically, I can run them, and they all work exactly as intended (and in only one instance). I have tried quite a few methods of autostarting these scripts, and I have found that using a desktop entry in .config/autostart directory to be my preferred way of doing it. I have also tried editing rc.local, crontab, systemd, and entries in .config/lxsession/LXDE-pi/autostart with no more success.
The issue is that when I have the scripts running at boot, there is a duplicate of the script running (I have it set to open a new instance of LXterminal, though there are not duplicates of the terminal). The script runs at boot just fine, but I am cannot figure out why there seems to be a "ghost" version of the script too. I have the autostart commands set to write to log files that show that the scripts are running more than once. I have also tried this on a fresh raspbian install. Could someone help me figure this out? I'm at a loss on what my issue is. This is for use of Amazon Alexa.
This is what I have in /home/pi/.config/autostart/AlexaBoot.desktop:
[Desktop Entry]
Name=AlexaBoot
Exec=lxterminal -e "/bin/bash /home/pi/Desktop/alexa_boot.sh"
Type=Application
I can post what I have in the autostarted script if necessary. Thanks.
Found a fix for this. My solution is outlined on a similar Github issue, hopefully this is able to help someone with the same issue.

How to run gunicorn & nginx on system startup? [Ubuntu 14.04]

I got a VPS that runs a django app w/ gunicorn & nginx.
right now im starting the whole thing by runnig:
cd /srv/OmegaManager
gunicorn -c /srv/gunicorn_config.py OmegaManager.wsgi
sudo service nginx start
How can i make a script that start those services that way on system startup?
I'm pretty new to linux, so please be well explained :)
OS: Ubuntu 14.04
I suppose simplest solution for novice user (must work without problems) is put these commands to file /etc/rc.local (it must be in your system by default). This file executed during startup in most linux systems.
Place commands before last line with exit 0.
Make sure /etc/rc.local is executable (again, it must be OK by default).

Sahi scripts are not running through Putty

I started Sahi using putty but I got the following error during running scripts:
Script didn't start 150 ms.
I ran both Sahi and script through putty. It's a point to note that running through Linux terminal it's working fine. Please help me regarding this issue.
You might want to check if there's any difference between the environments (env) when running in a terminal and when running in Putty. Also, if those sahi scripts are bash, you can run it with bash -x to see what's going on inside.

Resources