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 https://www.digitalocean.com/community/articles/how-to-use-cron-to-automate-tasks-on-a-vps
I set my crontab to be:
(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 “script.sh” 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?
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!
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>
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
Ok, I’m a bit further with this now. I created a a bash file and called it <br> <br>small_cron.sh <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 ./small_cron.sh 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 small_cron.sh 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>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.