After CPanel updated in 2013 any cron scripts work in jailedshell regardless account have no shell or jailedshell ... All my scripts working fine when its started as usual under Apache, but I have problem to start the same scripts under cron.
Related
IM running a VPS server on Ubuntu 14.04 minimal x86. I connect to it using putty via SSH.
On the server i have a simple script that is starting a few instances of bots
nohup node /nodebots/bot10/server.js &
I use root as a user, so all the privileges and +chmod X are set properly (in my opinion)
The idea is that my node.js program is not excelent + the service im running the bots for sometimes has reboots, server crashes etc.
Ive installed crontab and at this moment struggling to set the script to be run at boot.
Ive used various solutions including trying to boot it via init.d , adding a line to rc.local and well using crontab -e. None of it helps.
Currently the code in crontab looked the following ways
`#reboot sh /nodebots/botsrun.sh`
#reboot root /nodebots/sh botsrun.sh
#reboot cd /nodebots/ && sh botsrun.sh
None of it helped.
Im new to Ubuntu, coding and even terminal commands. I would really apreaciate any kind of help. I will be more then grateful for a step by step tutorial on what im doing wrong and what should be done.
I'm trying to start a script every time I start my amazon micro instance (amazon linux ami).
I tried to put it in /etc/init.d/ and linkted it to /etc/rc.d/ but the script is not executed.
I've also looked at user-data scripts, but as I understand the documentation they are only executed on the first startup of the instance.
What do I have to do to run my script on every startup?
Init.d/rc.d are primarly used for services. Any scripts that you install here have to be enabled to run at boot chkconfig service on.
Since it sounds like you are really just running a one time script. You can set it up to run with cron using the #reboot flag instead of providing a time.
Been messing around with XAMPP Cron Jobs for awhile and can't seem to get these to work right. This is being run on my personal computer for Mac OSX Yosemite. Using the terminal to make this work. The script is a PHP file. I put the default application to open up in a browser. It runs the cron job but it opens it up as if it is a text file and not as if it is a php script.
I did test this individually script separate from the cron and it works fine. Just for testing purposes I have it just writing to basic txt file. The paths are the default that pretty much comes with XAMPP.
Example of cron job in terminal
1 * * * * /usr/bin/open /Applications/XAMPP/xamppfiles/htdocs/rest of my path/write.php
The cron job does pull up the script in the default browser but is read like a text file.
So in the URL bar it starts off with file:// and than the cron job command path listed in the example.
Two questions:
1 Is there a way to make this execute the same way if I visited the webpage?
2 Is there a way to make this run in the background?
Thanks for any input.
I created a cronjob with sudo crontab -u USERNAME -e and tried to start my node.js app after each reboot.
It had worked well at another server.
But this time, I installed the Node.js via nvm
Then tried to run the same cronjob lines, but every time after reboot it failed. I tried to figure out all the related folders and tried again to run as different lines. When I check with forever list, server shows that no process is running.
#reboot /home/USERNAME/.npm/forever start -c /home/USERNAME/.nvm/current/bin/node /home/USERNAME/APPNAME/app
#reboot /home/USERNAME/.npm/forever start /home/USERNAME/APPNAME/app
#reboot /usr/local/bin/forever start -c /home/USERNAME/.nvm/current/bin/node /home/USERNAME/APPNAME/app
I think that the reason is somehow related with nvm. But I am not sure of that. I don't want to do anything unnecessary unless I am fully sure about it.
Edited July 26, 2015
Though I have used the npm's forever module to deploy nodejs production apps, I really do not see the need to use it on linux based servers as there are so many system level alternatives available.
One of them is upstart. It will help you run your scripts as system level services. Amazon Web Services also use upstart in their Elastic Beanstalk nodejs tiers to keep nodejs apps running forever.
If you really just need to get down to it, here is a link to run your nodejs app as an upstart service.
However, it is not limited to deploying nodejs apps only and if you learn upstart, you will be able to do a lot of things with it. Here is a link for that as well.
If your original approach was preferable (as it was in my case) you can fix your scheduled cron job by explicitly passing the path to node like this: (found in this answer)
#reboot /root/.nvm/versions/node/v7.1.0/bin/node /root/.nvm/versions/node/v7.1.0/bin/forever start /var/www/server.json
Apparently NVM works in magic by setting up some system paths which aren't setup at the moment the cron jobs run.
I have written some cron jobs using the crontab feature on my ubuntu. Can I use Jenkins to monitor these jobs?
Edit 1: I have Jenkins already installed on my local machine: localhost:8080. So right now, I have cronjobs running on crontab. I cannot create a new job on Jenkins and run them on Jenkins's shell because of certain requirements.
Following Pragmatic's solution, I looked at https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs and tried to sudo apt-get install jenkins-external-tool-monitor, but I am getting: E: Couldn't find package jenkins-external-tool-monitor. Any work arounds?
Edit 2: I have figured it out. Very Important: I tried to set this up using jenkins-core-1.47*.jar file, and it didnt work. It did work with jenkins-core-1.466.jar. So if you are using some .jar file, stop jenkins, replace it with a jenkins.war that corresponds to jenkins-core-1.466.jar and start jenkins after. That should work!
Yes, you can do that!!
Have a look at this link: Monitoring external jobs.
I could have explained the whole method here itself but the details in the question were minimal.
Hope this helps you.
Possible...See this
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs
As others have stated above, follow: https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs
Then I started getting this ugly error: https://issues.jenkins-ci.org/browse/JENKINS-14107
If you face this problem as well, replace the current jenkins.war file with one from version 1.466. That is the one that worked for me. Before I replaced the war file, I stopped the jenkins server by : /etc/init.d/jenkins -stop and then replaced the war file and then started the server: /etc/init.d/jenkins -start
An alternative approach is to use an instance of Jenkins to replace your cron jobs entirely.
See:
Drop that cron; use Hudson instead
Replace Local Cron With Jenkins