Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a cron script to check if my minecraft server is running or not and if it is down to run the start up script.

Here is what I have and this is the error I get when running it

/bin/sh: 1: Syntax error: EOF in backquote substitution

the line in my CRON file:

10,20,,30,,40,,50 * * * * cd /home/jon/FTB/FTBnew; RUNNING=grep minecraft; if [ -n "$RUNNING" ] ;then end ;else Bash
share|improve this question
What exactly is your question? You're trying, but where are you stuck? Please specify. – the_Seppi Jan 20 '14 at 19:43
i am getting this error when i run it /bin/sh: 1: Syntax error: EOF in backquote substitution – smally2189 Jan 20 '14 at 19:52
Please secify such information as an edit to your original question. – the_Seppi Jan 20 '14 at 19:58
i removed 'ps -ef from the sript and added to the info /bin/sh: 1: Syntax error: EOF in backquote substitution – smally2189 Jan 20 '14 at 20:08
Do you see the edit button below your question text? Please use it instead of posting answers that are converted into comments. – the_Seppi Jan 20 '14 at 20:10

There are various problems with your cron entry and your script.

First, your format for the cron fields (indicating time of execution) are wrong, you're using double commas and they should be single. Also, if you want this to run every 10 minutes, it's easier to do this:

*/10 * * * * 

Next, the script part. Properly formatted, your script looks like this:

cd /home/jon/FTB/FTBnew
RUNNING=grep minecraft
if [ -n "$RUNNING" ] ;then
else Bash

grep minecraft lacks a parameter, and the syntax to assign the result of a command to a variable is wrong, it should be something like:

RUNNING=`ps waux | grep minecraft`

but even that is not entirely correct, this is just an example.

Next, if the condition for the if is met, you want to execute an "end" command which does not exist.

After that, the else clause also specifies a non-existent command (it would be bash in any case, not Bash).

Finally, the if clause is not properly terminated, so it definitely won't work.

What you're trying to do is relatively straightforward, so even if you're just beginning with cron and shell scripting it will be easy, but I suggest you read some documentation first, so you can understand what you have to do, and have a document to refer to in case you need a quick refresher on how these commands work. If after reading this you're still having trouble, you're welcome to ask for comments and help.

First, a tutorial on how to use cron:

Then a bash programming tutorial:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.