Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


cronjob and screen
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

cronjob and screen

trexostrexos Member

Hello,

I'm trying to create a restart script for my CS:S server, so I have a file called restart.sh which contains a part which kills the server (its running over screen) and a part which should start the server again. My script works great when I run it on my own, but with crontab it doesn't work. I already checked google and I read that I should use the -dmS tag for cronjob and screen, but it doesn't work either. I use this line to start the server again:
screen -dmS $SERVER ./srcds_run $PARAMS $PARAMS2

But the CS:S server doesn't start with cronjob. Can anybody help?

thanks :)

Comments

  • netomxnetomx Moderator, Veteran

    can you gice us your cron command?

  • trexostrexos Member

    @netomx said:
    can you gice us your cron command?

    Sure :)
    30 * * * * bash /home/css/css_server/restart.sh

    Is it possible that I should give execute rights to others? Currently the rights are: -rwxr--r--

  • netomxnetomx Moderator, Veteran

    re you editing with crontab -e (or -u) or directly to /etc/crontab ?

  • trexostrexos Member

    I do it with crontab -e

  • Have you tried restarting the cron service? Had issues like this before.

  • netomxnetomx Moderator, Veteran

    @trexos said:
    I do it with crontab -e

    in what user?

  • trexostrexos Member

    @netomx said:
    in what user?

    in css user

  • trexostrexos Member

    I had this problem with a minecraft server as well, but I can't remember how I fixed it.

  • Often, when something works at the command line but fails in a cron job it's because of the path environment.

    Try providing the full path to screen, e.g., /usr/bin/screen

    which screen will tell you where it is.

    Thanked by 1netomx
  • trexostrexos Member

    @sleddog said:
    Often, when something works at the command line but fails in a cron job it's because of the path environment.

    Try providing the full path to screen, e.g., /usr/bin/screen

    which screen will tell you where it is.

    so I should use /usr/bin/screen -dmS $SERVER ./srcds_run $PARAMS $PARAMS2 instead of screen -dmS $SERVER ./srcds_run $PARAMS $PARAMS2?

  • trexos said: so I should use /usr/bin/screen -dmS $SERVER ./srcds_run $PARAMS $PARAMS2 instead of screen -dmS $SERVER ./srcds_run $PARAMS $PARAMS2?

    Yes, if you screen binary is indeed at /usr/bin/screen

    Also, ./srcds_run is a relative path which may be an issue for cron. Try substituting an absolute path like /full/path/to/srcds_run

    Thanked by 2netomx trexos
  • trexostrexos Member
    edited July 2014

    @sleddog said:

    Well the restart.sh is located in the folder where the srcds_run is and cronjob only starts the restart.sh

    With this comman screen -dmS $SERVER ./home/css/css_server/srcds_run $PARAMS $PARAMS2 it doesn't start anymore, even when I start the restart.sh myself.

  • trexos said: ./home/css/css_server/srcds_run

    Remove that leading dot.

    Thanked by 1trexos
  • DylanDylan Member

    Tip: use tmux instead of screen. It's a superior, smarter (terms and keybindings that make sense), actively developed alternative.

    https://www.digitalocean.com/community/tutorials/how-to-install-and-use-tmux-on-ubuntu-12-10--2

  • MunMun Member

    You should not need to restart your server everyday, if you do so then you have an issue with a plugin or aren't changing your map on a frequent enough basis.

    Mun

  • netomxnetomx Moderator, Veteran

    what @sleddog says

  • trexostrexos Member

    @sleddog said:

    Thanks that worked :)

    Thanked by 1sleddog
  • iceTwyiceTwy Member

    I had a similar cronjob to run when I used to host an Electrum node. I wrote a post on my blog when I found what was wrong (dumb syntax errors) - have look here, it might help you.

    Thanked by 1trexos
Sign In or Register to comment.