Problems in setting up the CronJob

Hello,

I have a rails application and trying to setup the cronjob to send out the emails.

Here is my Cronjob,

20 9 * * * /bin/sh -c "cd /srv/www/railsappdirectory && RAILSENV=development /usr/bin/env rake email:sendsignupemail >> /srv/www/railsappdirectory/log/cronlog.log 2>&1"

When I try this, I get an Error.

Error Message:

/usr/bin/env: rake: No such file or directory

Looks like the Path problem. Any help would be appreciated.

Thanks,

Muni.

1 Reply

Don't do this. Create a ~/bin directory, make a shell script that does everything you want it to, and have cron execute it. Bear in mind that cron doesn't do proper variable substitution and sets a limited PATH (which is why it can't find rake in the path). See crontab(5) manpage for details.

Also, don't append directly to log file. Use a pipe agent that supports rotation.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct