Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am on shared hosting and I'm trying to schedule cronjob to run every now and then. Via cPanel I scheduled to execute my script but even though that according to my host support the cronjob runs, the script doesn't seem as doing anything. The cron job command I set via cPanel is:

/bin/sh /home1/myusername/public_html/somefolder/cronjob2.sh

and the cronjob2.sh

#!/bin/bash
/home1/myusername/public_html/somefolder/node_modules/forever/bin/forever stop 0

when via SSH I execute:

/home1/myusername/public_html/somefolder/cronjob2.sh

it stops forever process as needed. From cronjob doesn't do anything.

How can I get this working?

EDIT:

So I've tried:

/bin/sh /home1/username/public_html/somefolder/cronjob2.sh >> /tmp/mylog 2>&1

and mylog entries say:

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

It seems that forever needs to run node and this cannot be found. How would I possibly fix this?

share|improve this question
    
It should do it, but I want to ask to you: does it stop forever process even if you execute the script with `/bin/sh /home1/myusername/public_html/somefolder/cronjob2.sh'? –  Hastur Jun 3 '14 at 22:36
    
if I execute script `/bin/sh /home1/myusername/public_html/somefolder/cronjob2.sh' it does work. I also updated my answer –  spirytus Jun 4 '14 at 0:20

1 Answer 1

up vote 0 down vote accepted

You may need to define your PATH and other environment variables at the start of your script. Type "set" to show their values in your current shell, then copy/paste whatever you need, adding lines until your script works.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.