Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
helgehelge123

How to Add Scripts to Ubuntu's Autostart?

#!/bin/bash
cd /home/comp/
./srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -port 27050 -tickrate 128

Save this as e.g. /home/comp/runcs.sh and make it executable (on the command-line, you'd make it executable with chmod ugoa+x runcs.sh), then run crontab -e, and at the bottom add @reboot /home/comp/runcs.sh

 

Explanation: cron is a program that basically executes stuff at certain times, crontab -e allows you to add or remove things for it to run. @reboot tells cron to run the following command when the PC has finished booting up, so your CS-script will run then.

Recommended Posts

Posted · Original PosterOP

Hey guys,
I'm trying to setup a few CSGO server and the first server is working but it won't start after linux reboots.

Can somebody explain a simple way to add the .sh script to the autostart?

 

I'm a total noob btw, my knowledge only reaches cd, mkdir command and stuff like that.

 

The server is running Ubuntu 18.04 and I've got a gui.

 

Please help

 

cd /
cd /home/comp/
./srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -port 27050 -tickrate 128

This is the code, btw

Link to post
Share on other sites
Posted · Best Answer
#!/bin/bash
cd /home/comp/
./srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -port 27050 -tickrate 128

Save this as e.g. /home/comp/runcs.sh and make it executable (on the command-line, you'd make it executable with chmod ugoa+x runcs.sh), then run crontab -e, and at the bottom add @reboot /home/comp/runcs.sh

 

Explanation: cron is a program that basically executes stuff at certain times, crontab -e allows you to add or remove things for it to run. @reboot tells cron to run the following command when the PC has finished booting up, so your CS-script will run then.


Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to post
Share on other sites
Posted · Original PosterOP
48 minutes ago, WereCatf said:

#!/bin/bash
cd /home/comp/
./srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -port 27050 -tickrate 128

Save this as e.g. /home/comp/runcs.sh and make it executable (on the command-line, you'd make it executable with chmod ugoa+x runcs.sh), then run crontab -e, and at the bottom add @reboot /home/comp/runcs.sh

 

Explanation: cron is a program that basically executes stuff at certain times, crontab -e allows you to add or remove things for it to run. @reboot tells cron to run the following command when the PC has finished booting up, so your CS-script will run then.

i'm pretty sure i'm doing somthing wrong when I try to save the crontab -e
i'm getting this error: E37: No write since last change (add ! tp override)

 

How do I save and quit the nano file editor? ctrl o and ctrl x don't seem to work for me.

 

I'm really new to ubuntu and the terminal. Please give me detailed steps

 

edit: missspelled nano
 

crontab error.jpg

Link to post
Share on other sites

Looks like it defaults to vi; press i to be able to edit, esc to quit the mode, then do :wq to save and quit

 

Or to use nano you can run: EDITOR=nano crontab -e


Link to post
Share on other sites
Posted · Original PosterOP
Just now, duncannah said:

Looks like it defaults to vi; press i to be able to edit, esc to quit the mode, then do :wq to save and quit

What is :wq?

Link to post
Share on other sites
Posted · Original PosterOP
2 minutes ago, duncannah said:

Looks like it defaults to vi; press i to be able to edit, esc to quit the mode, then do :wq to save and quit

 

Or to use nano you can run: EDITOR=nano crontab -e

OMG, Thanks a lot, Love you!

Link to post
Share on other sites
1 minute ago, helgehelge123 said:

What is :wq?

It's a vi command, simply type that when you're out of the insert mode then press enter


Link to post
Share on other sites

The proper way to do this is using systemd service but whatever, cron will still do the job... Nevertheless is part of systemd anyway

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×