LogoLogo
  • Home
  • Getting Started
  • Configuration
    • LinuxGSM Config
    • Game Server Config
    • Start Parameters
    • cronjobs
    • Running on Boot
    • Running Multiple Game Servers
    • IP Address Configuration
    • LinuxGSM Stats
  • Commands
    • install
    • start-stop-restart
    • monitor
    • test-alert
    • console
    • debug
    • update
    • check-update
    • force-update
    • validate
    • update-lgsm
    • backup
    • map-compressor
    • details
    • mods
    • skeleton
    • fastdl
    • change-password
  • Game Servers
    • 7 Days to Die
    • Arma 3
    • ARK: Survival Evolved
    • Call of Duty 4
    • Dont Starve Together
    • Counter-Strike 2
    • Counter-Strike: Global Offensive
    • Factorio
    • Garry's Mod
    • Insurgency: SandStorm
    • Killing Floor 2
    • Minecraft: Java Edition
    • Multi Theft Auto
    • Rust
    • Sven Co-op
    • Trackmania Nations Forever / Trackmania United Forever
    • TeamSpeak 3
    • Unreal Tournament 99
    • Unreal Tournament 2004
    • Unreal Tournament 3
    • Valheim
    • Xonotic
    • The Front [WIP]
  • Networking
    • IP Address
    • Ports
    • Source Engine
  • Alerts
    • Discord
    • Email
    • IFTTT
    • Pushbullet
    • Pushover
    • Rocket.Chat
    • Slack
    • Telegram
  • Dependencies
    • Java
    • tmux
    • jq
    • gamedig
    • glibc
  • Features
    • ANSI Colors
    • Stop Mode
    • Log Management
    • Message Display Time
  • SteamCMD
    • Steam Master Server
    • Game Server Login Token
    • Branch
    • LAN Discovery
    • Workshop
    • Error Codes
  • Linux
    • distro
    • ftp-scp
    • file-ownership
    • firewalls
    • network-interfaces
    • permissions
    • Symlinking and ln command
  • Troubleshooting
  • FAQ
  • Guides
    • Security
    • Make Webserver Case Insensitive
    • Sourcemod and Metamod:Source
  • Other
    • server-migration
    • basic-usage
    • brand
Powered by GitBook
On this page
  • Crontab
  • Cronjob as a user or root
  • User cronjob
  • Root cronjob
  • Cronjob Timing Examples
  • Every single minute
  • Every 30 minutes
  • Every hour
  • Every two hours
  • Every two hours at 30 minutes past the hour
  • Every day at 5:10 PM
  • Every Wednesday at 1 AM
  • Every Five Days at 1 AM
  • Cronjob Generator
  • LinuxGSM Cronjobs examples
  • Daily cronjob
  • Every X Time cronjobs
  • Complete Example
Edit on GitHub
Export as PDF
  1. Configuration

cronjobs

PreviousStart ParametersNextRunning on Boot

Last updated 4 years ago

To automate LinuxGSM you can set scheduled tasks using cronjobs, to run any command at any given time.

Commonly used scheduled tasks are:

  • Automatically check for updates

  • Automatically check for server crash and restart if needed

  • Automatically keep LinuxGSM up to date

  • Automatically restart the server at a given time

  • Automatically update and restart the server

Crontab

To access and edit your cronjobs use crontab.

crontab -e

Cronjob as a user or root

It is possible to set up cronjobs as any user including root. The recommended way is to set up cronjobs using the game servers user account. However, If you run several game server installations on your server you may want to centrally manage cronjobs then using root.

User cronjob

* * * * * [/path/to/script] [command] > /dev/null 2>&1

Root cronjob

* * * * * su - username -c '[/path/to/script] [command]' > /dev/null 2>&1

Cronjob Timing Examples

Every single minute

* * * * *

Every 30 minutes

*/30 * * * *

Every hour

0 * * * *

Every two hours

0 */2 * * *

Every two hours at 30 minutes past the hour

30 */2 * * *

Every day at 5:10 PM

10 17 * * *

Every Wednesday at 1 AM

0 1 * * * 3

Every Five Days at 1 AM

0 1 */5 * *

Cronjob Generator

LinuxGSM Cronjobs examples

Replace username and gameserver with your own details.

Daily cronjob

Here is an example of a user based cronjob for a daily restart at 5 am.

0 5 * * *  /home/username/gameserver restart > /dev/null 2>&1

Here is an example of a root based cronjob for a daily restart at 5 am.

0 5 * * *  su - username -c '/home/username/gameserver restart' > /dev/null 2>&1

Every X Time cronjobs

Here is an example of a user based cronjob to monitor your server every 5 minutes.

*/5 * * * *  /home/username/gameserver monitor > /dev/null 2>&1

Here is an example of a root based cronjob to monitor your server every 5 minutes.

*/5 * * * *  su - username -c '/home/username/gameserver monitor' > /dev/null 2>&1

Complete Example

Below is a recommended basic example and will do the following:

  • Monitor your server every 5 minutes.

  • Check for an update every 30 minutes, update and restart only if an update is detected.

  • Restart and check for an update every day at 4:30 AM

  • Update check and update LinuxGSM every Sunday at midnight.

*/5 * * * * /home/username/gameserver monitor > /dev/null 2>&1
*/30 * * * * /home/username/gameserver update > /dev/null 2>&1
30 4 * * *  /home/username/gameserver force-update > /dev/null 2>&1
0 0 * * 0 /home/username/gameserver update-lgsm > /dev/null 2>&1

If you are not used to setting up cronjobs you can use as a great reference to get started.

(update command)
(monitor command)
(update-lgsm command)
(restart command)
(force-update command)
crontab.guru