What I have now is a node server (with forever.js in Ubuntu 14.04 LTS) which is needed to start each time server PC starts.
So, to do that what we need is this command (every time PC start or restarts)-
forever start /var/www/websocket/websocket.js
If I run this command in direct command line, it works fine.
But I want it automatically start when server PC turn on or restart.
So what I have done (according to https://stackoverflow.com/a/13388741/2193439 ) is-
Run crontab -e
and put this code in the console-
@reboot forever start /var/www/websocket/websocket.js
like this-
And to check my corn log, I have done this-
sudo grep --color -i cron /var/log/syslog
And found something like this-
But I am finding the server is not running by this-
forever list
and having - No forever processes running
But if I run this-
forever start /var/www/websocket/websocket.js
And then run this-
forever list
Then I am having this-
And I am confirming you that crontab is also running because if I change this-
@reboot forever start /var/www/websocket/websocket.js
To this-
@reboot cd /var/www/websocket/ && touch cron_try.txt
I am having the file each time PC restarts.
I have already tried this-
- Automatically start forever (node) on system restart
- Automatically restart node server
- http://www.hacksparrow.com/make-forever-reboot-proof-with-cron.html
- https://github.com/foreverjs/forever/issues/58
And this-
cronjob does not execute a script that works fine standalone
Is almost my problem. But I had set it during reboot and for Node forever.js.
So it does not solve my problem.
Can anyone please help?