Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Condition supplied in cron job returns "No such file or directory"

Tags:

bash

cron

redhat

I am attempting to execute this code in a cron job:

a=`/home/mailmark/node/bin/forever list`; if [ "$a" == "No forever processes running" ]; then forever start /api.js; fi

The file in question, 'forever' contains this shebang:

#!usr/bin/env node    

It returns this response:

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

But I have this code on the last line of the .bashrc file:

export PATH=/home/mailmark/node/bin:$PATH

What should I do to make my cron work?

like image 595
austincheney Avatar asked May 26 '11 12:05

austincheney


3 Answers

Use the full path to node:

#!/usr/bin/env /home/mailmark/node/bin/node
like image 171
blahdiblah Avatar answered Nov 20 '22 04:11

blahdiblah


cron doesn't run in a "login shell", so .bash_profile and .bashrc are not loaded.

like image 41
eduffy Avatar answered Nov 20 '22 03:11

eduffy


add . $HOME/.bashrc to the beginning of your cron job.

like image 41
glenn jackman Avatar answered Nov 20 '22 05:11

glenn jackman