0

Hello then I state that something very strange happens to me, which had never happened to me. So I have a node.js application that runs perfectly on a centos server! Once the application has been loaded on the server, boot with node server.js and everything is working on perfection! As a reboot I set a cron to start the server node with this syntax:

**@reboot node /var/www/html/app/main.js**

the problem is that when I restart the machine the cron starts correctly node.js but when I have to do the change of directory below I have this error:

Node.js Code:

process.chdir('./Model');

Directory Tree:

/var/www/html/app

/var/www/html/app/main.js

/var/www/html/app/Model

Error: ENOENT: no such file or directory, uv_chdir

2
  • What's the error? Can you please update the question including the error? Commented Jun 25, 2018 at 15:23
  • @yaswanth I have add error Commented Jun 25, 2018 at 15:25

2 Answers 2

2

Please refer to this question.

Just adding a node command in cron won't work. You need to do cd into your project root dir and execute node command.

Sign up to request clarification or add additional context in comments.

Comments

1

What is current working directory of your process? Try console.log(Starting directory: ${process.cwd()}); to see if it is /var/www/html/app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.