cd ~ might not work (since tilde expansion is not universal). Prefer
cd $HOME to it (which is guaranteed to do the same for all implementations of
/bin/sh ...) ..... Remember that POSIX
/bin/sh) is generally not
bash (and your
/bin/sh might not be fully POSIX compliant, but more "bourne"-like)!
Of course, you could add something like
pwd > /dev/stderr in your script (for debugging purposes).
wine generally needs an X11 server to display windows. And a program started from
cron generally don't any X11 server or terminal. So
wine is probably failing to start (from your
cron job). You might need to set some
DISPLAY variable for Xlib. But you might use Xvfb, see here.
At last, pgrep(1) is scanning processes. Either use
ps aux | grep "D2GS" or learn how to use
I recommend using
echo something > /dev/stderr or better
echo or printf(1) (with a suitable redirection) or logger(1) in your script, at least for debugging purposes (in several places).
And I won't redirect
wine-s stderr and stdout to
/dev/null at least during the debugging phase. Can't you code (at least temporarily during debugging)
wine "C:/D2GS/D2GS.exe" >> /tmp/wine.out 2>&1 and look into
/tmp/wine.out with some pager like
cron (and your shell script) is not using your interactive
PATH variable. You should consider setting it explicitly in your script (or
crontab). See environ(7).