Getting Crons to work on Ubuntu

  • Posted on May 14, 2014
  • jonnnyAsked by jonnny

I was encouraged to reach out to the community from the DO support for some help with Crons. I’m on Ubuntu and followed the guide on creating a cron

I set my crontab to be:

          • /srv/users/serverpilot/apps/mywebsite/protected/yiic.php email emailJob

(I’m using the Yii framework btw)

I tried to run the command directly through Putty by loading /srv/users/serverpilot/apps/mywebsite/protected/yiic.php email emailJob

and nothing seemed to happen. So I emailed DO. They said try a BASH script, make a new script “” and upload it to “#!/bin/sh”. I made the script but when I used FileZilla to access that directory to put the new script I got the following error:

Error: Directory /bin/dash: no such file or directory Error: Failed to retrieve directory listing

So I’m unsure really of how to proceed or what i’m doing wrong?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Ok, I’m a bit further with this now. I created a a bash file and called it <br> <br> <br> <br>And I’m just going to use that to run my Commands for a cron. <br> <br>But I wanted to test it actually worked, so I executed it using ./ and I get <br> <br>…/srv/users/serverpilot/apps/myapps/protected/yiic.php: 1: …/srv/users/serverpilot/: No such filetected/yiic.php: cannot open ?php <br>…/srv/users/serverpilot/apps/myapps/protected/yiic.php: 2: …/srv/users/serverpilot/apps/myapps/protected/yiic.php: //: Permission denied <br>…/srv/users/serverpilot/apps/myapps/protected/yiic.php: 3: …/srv/users/serverpilot/apps/myapps/protected/yiic.php: Syntax error: word unexpected (expecting “)”) <br> <br>A couple of things I didn’t know. <br> <br>1) why is it saying it can’t open ?php which is the opening tags to my frameworks command settings? <br> <br>2) Am I to take it that my path is wrong, if so where is the cron executed from so I can adjust the path, I just assumed that as my is in the root folder my path would work as my /srv/ folder is not in the root folder but on the same level? <br> <br>

Hi Andrew <br> <br>Yiic.php is a Yii framework file, it runs commands for Yii. Oh, I see about the file now, in that case what is the correct directory for me to place this Bash script? <br> <br>Thanks <br> <br>Jonny

Hi Jonny! <br> <br>Is yiic.php something you wrote your self? Could you add some debugging statements that print to the console so you can tell if it is actually running when you execute it manually? <br> <br>As far as the script, “#!/bin/sh” isn’t the location that you should upload it to, it is what the first line of the file should be. Like so: <br> <br><pre> <br>#!/bin/sh <br> <br>/srv/users/serverpilot/apps/mywebsite/protected/yiic.php email emailJob <br></pre>