Starting something at a certian time and then stopping it - automation

I run a Garry's mod server and I want to stop my server at 7AM then start it again. To safely close the server it requires me to type quit in the server console. How could I make a script that rules quit in the console then starts my start.sh file after that is done? I was looking at crontabs but they are confusing to me.

I'm not familiar with Garry's mod servers, but in general you can do the following in a cron file:
0 7 * * * quit && /path/to/start.sh
the first bit ensures that the command is run at 7AM of machine's time every day. You can use crontab guru as a simple UI that shows what the numbers and * mean on cron scheduling.
I've assumed that quit closes the piece of code running on the machine, and doesn't restart or shutdown it down.
Also make sure to use absolute paths when running scripts from cron files.

Related

Ubuntu Server - Not able to run server in background

I am running server for Rimworld on RapsberyPi 4B.
I have problem with running it in background, when i start the server:
./Open\ World\ Server
Everything starts but name of CMD is the name of the server and when i close the CMD window server will stop.
I´ve tried many things like & after the command, nohup and others. Also I´ve tried pm2 as it is running my discord bot, but everything that I´ve tried is stil saying that Open World Server is "Stopped".
So what i need is:
Run this server in background
Start this server after restart automatically.
Thanks everyone for help :)
So I have found the solution.
I´ve tried pm2 many times but never this way.
nano
#!/bin/bash
Command you want to be executed. In my case
./Open\ World\ Server
Save this like run.sh or whatever.
After that simply do this
pm2 start run.sh
And that is all you need. You can do the same way with minecraft server or other things you want to run in background and start with reboot of your Pi or other devices.

Which process runs Webmin Scheduled Functions?

Exactly who wakes up and runs the entries in Webmin Scheduled Functions? doesn't seem to be crond. is it miniserv.pl?
Looking at miniserv.pl file, tells me that as miniserv is always running, it effectively manages its cron jobs.
# Initially read webmin cron functions and last execution times
&read_webmin_crons();
Search through the file for webmin_crons string, you will get all info you need in this regard.
As far as I'm aware, we don't use system crond to run internal scheduled functions.

Rundeck - reboot server job

I have a rundeck job that reboots a server, it sends the command "sudo reboot". This works and the server is rebooting.
The problem is that rundeck doesn't get a signal back so the job fails.
Is there a way to make this work and get a complete signal back in rundeck?
Perhaps wrap your command in a script, background the reboot operation, and return 0? I'm doing something similar with a set of development VMs, but I'm using virsh. I don't see why this couldn't be done with a physical server:
#!/bin/bash
ssh rundeck#yourserver sudo reboot &
exit 0
You may need to experiment a bit with the ssh options (perhaps '-f' and/or '-n') to get this to work properly.
Well playing around now I just used as Local Command step:
ssh ${node.username}#${node.hostname} "reboot & exit"
The return code is ZERO and everybody is happy.

run binary service in Openshift and control it

I made a simple binary application like a clock and run it in server but when I close ssh connection,application will be closed.
But i want clock run all the time for example.
Then I made a simple service and I want to run it in server but I do not know how install,control and resume it after I close ssh connection.
Try adding an & after it to put it into the background, then you can close your ssh session and leave it running. You could also (if the binary is in git) use an action hook to run it (but you still need to include the &), something like..
$OPENSHIFT_DATA_DIR/clock &
If it was located in your $OPENSHIFT_DATA_DIR directory.

Kill localhost:3000 process from Windows command line

So im using ruby on rails in windows (i hear you all spitting your coffee onto the screen), its only a short term thing. (using ubuntu at home) So i tried to fire up webrick this afternoon and i get the error message
TCPServer Error, only one usage of each socket address is normally permitted
So it seems as if port 3000 is still running from last week? My question is how do i kill the process from the Windows command line. normally i have to press ctrl and pause/break in windows as ctrl c is not working which is only killing the batch process it seems..
Any solutions welcomed
Edit
So it seems as if
tasklist
will give me the list of processes, but where do i find the process for running the webrick server?
ruby.exe is not listed as a running process
Try using netstat -a -o -n to determine the pid of the process running on port 3000. Then you should be able to use taskkill /pid #### to kill whatever process is running on that port.
Probably not the most graceful way to do it, but I think it should work.
EDIT
You'll probably have to also use the /F flag to force-kill the process. I just tried it on my local machine, and that worked fine.
Go into rails_project\tmp\pids and delete the .pid file in there.
run:
rails server