Getting Crons to work on Ubuntu

May 14, 2014 2.5k views
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?
3 Answers
Hi Jonny!

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?

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:


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

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?


Ok, I'm a bit further with this now. I created a a bash file and called it

And I'm just going to use that to run my Commands for a cron.

But I wanted to test it actually worked, so I executed it using ./ and I get

../srv/users/serverpilot/apps/myapps/protected/yiic.php: 1: ../srv/users/serverpilot/: No such filetected/yiic.php: cannot open ?php
../srv/users/serverpilot/apps/myapps/protected/yiic.php: 2: ../srv/users/serverpilot/apps/myapps/protected/yiic.php: //: Permission denied
../srv/users/serverpilot/apps/myapps/protected/yiic.php: 3: ../srv/users/serverpilot/apps/myapps/protected/yiic.php: Syntax error: word unexpected (expecting ")")

A couple of things I didn't know.

1) why is it saying it can't open ?php which is the opening tags to my frameworks command settings?

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?

Have another answer? Share your knowledge.