ID:967857
 
Code: 2012
screen DreamDaemon /root/Naruto/Naruto.dmb


Problem description: Does somebody know how to make a VPS runs a command after rebooting? I tried editing bashrsc but it only ran when I logged into the terminal.

I wanted it to run this command:

screen DreamDaemon /root/Naruto/Naruto.dmb 2012

Any idea?


Sorry, I'm not very familar with this and was hoping someone else would've helped you out, but since no one has, I'll give it a shot.

What exactly does screen do on your VPS? The only thing I've known it to do with host I've dealt with before is keep track of errors, if that's what you're wanting; You could just use world.log.

world/New()
log=file("file.txt")
..()
In response to NNAAAAHH
BYOND also has a tag you can add called -logself which will log all startup errors and normal errors you can just add it to the command.

As for making the command run at start up you have a few ways the easiest is to add it as a cron job

create a .sh script using your fav editor I'll be using nano

cd /home
nano startup.sh


paste in the following

#!/bin/bash

DreamDaemon /root/Naruto/Naruto.dmb -logself -trusted


And save the file, Now to add it to the cron

crontab - e


You might see something like so

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command


With no entries (depends on your system and if you have ever added anything)

So we want to run a command if the VPS reboots itself

@reboot /home/startup.sh


And you are done. reboot the server check that it works if it doesn't go look at less /var/logs/cron (it may differ depending on OS) you can exit less by pressing q

If you have any errors have a look see that everything is done correctly if it is post the errors here and we can help you out some more.

[EDIT] Can you move this post to Linux Help as it's not really a developer issue and has some valuable information for Linux newbies :)