Crontab for Wine Services

Questions about Wine on Linux
Locked
htorbov
Level 2
Level 2
Posts: 21
Joined: Wed Feb 01, 2012 11:33 am

Crontab for Wine Services

Post by htorbov »

I'm starting my service using:

Code: Select all

wine net start D2GS
Can I check with crontab and bash is the specified process running?

I've tried with this, but it didn't worked:

Code: Select all

# crontab
* * * * * /home/trinity/servers.sh

# servers.sh
if ! ps aux | pgrep "wine"; then
    wine net start D2GS
fi
The crontab wouldn't work, because it's a GUI program. I tried to add `&& export $DISPLAY=:0`, but nothing changed.
The servers.sh shouldn't work, because it's not looking for the process correctly, but only for `wine`.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: Crontab for Wine Services

Post by Bob Wya »

@htorbov

Hmmm, I'd recommend looking up:

Code: Select all

man pgrep
:lol:

crontab is not really the best place for a "persistent" wine service.

If you're running your Diablo II Game Server from a Linux Desktop Environment... Then it would be best to just use the autostart facility of that Desktop Environment.

E.g. for Plasma 5, scripts placed in:

Code: Select all

~/.config/autostart-scripts/
will be run when the DE starts up.

Other Desktop Environments are available! So see: Arch Wiki: Autostarting ...

I'd recommend a combined startup + keep-alive script like:

Code: Select all

#!/bin/bash

while ((1)); do
  while pgrep 'd2gssvc.exe'; do
    sleep 1
  done
  wine net start 'D2GS.exe'
done
That modified script should do the job!

If you want to run an application, under Wine, on a headless server then you have to start running something like a Virtual X Server ...
That's getting a bit more involved though! :shock:

Bob
Locked