0

First post on this forum here :) I already saw this on the forum, but it if the crontab starts the script it gives out an error. (It works standalone.)

See this is my script. This is the Log.

And here is my crontab:

* * * * * /bin/bash /home/steam/arma3/restart.sh >> /home/steam/arma3/logs/checkonserv.log 2>&1

The "cannot found error" were fixed, but the execution of the arma3server file doesnt work.

Marc Ma
  • 101

3 Answers3

0

Very often a script such as this experiences a bash vs. sh invocation issue. In short, crontab defaults to what is explicit in the file as:

SHELL=/bin/sh

while your shell is likely running a bash invocation.

I would recommend:

  1. Adding a #!/bin/bash to the top of your script (if that is the SHELL of choice)
  2. Explicitly adding the /bin/bash to the crontab line such that:

    * * * * * /bin/bash /home/steam/arma3/restart.sh >> /home/steam/arma3/logs/crontabcheck 2>&

If errors persist, please provide an update.

Mark
  • 1,531
0

Ok, so i found a workaround about this:

  • Put your script in an infinite Loop
  • Wait for 1 min @ the end in the script (sleep 1m)
  • Execute the script with screen
Marc Ma
  • 101
0

Never assume that cron will work the same as running something manually. If you ever expect to run your script in cron, make sure your script sets up it's environment exactly as needed, and uses full paths to the commands you want to run.

Spaldam
  • 41