I am very new to shell script,in my company i need restart all application servers in production at or before 12.30 pm everyday.can i automate this process by shell script also will it affect any other application running on the server.
Thanks in Advance
At last i found answer to restart tomcat automatically by writing a simple script and setting-up that script on cron whatever time sequence i need restart application server.
Script
#! /bin/sh
SERVICE=/etc/init.d/tomcat7
$SERVICE restart
Cron job
30 12 * * * /root/restarttomacat.sh
It wont affect any other applications.
Related
I have some scripts that must be run under WSL, and must be run all the time. Currently, my Windows 11 randomly decides when it thinks it's convenient to reboot and install some updates. Is there a way to start WSL cron jobs automatically with Windows?
If this sounds like an XY Problem, I'd be more than happy to elaborate further.
I set up the cron job via crontab -e (and also sudo). I was expecting it to behave as it would on a regular Linux distro, but it doesn't do anything until I "sudo service cron start" and have at least one of the WSL windows open.
I am configuring an app at work which is on a Amazon Web Server.
To get the app running you have to run a shell called "Start.sh"
I want this to be done automatically after booting up the server
I have already tried with the following bash in the User Data section (Which runs on boot)
#!/bin/bash
cd "/home/ec2-user/app_name/"
sh Start.sh
echo "worked" > worked.txt
Thanks for the help
Scripts provided through User Data are only executed the first time the instance is started. (Officially, it is executed once per instance id.) This is done because the normal use-case is to install software, which should only be done once.
If you wish something to run on every boot, you could probably use the cloud-init once-per-boot feature:
Any scripts in the scripts/per-boot directory on the datasource will be run every time the system boots. Scripts will be run in alphabetical order.
I have created a script script.sh which contains
./ecc start pricingUpdater & >> /home/eceuser/Muthu/details/Latest.txt
where ecc is another script.
If I run the script manually by simply invoking ./script.sh I am able to start the utility:
Starting Oracle Communication Elastic Charging Controller 11.2.0.1 ...
-- Node 'pricingUpdater' started with PID 10705
^[[1m===>^[[m [{GridEventImpl
status: true
node: PricingUPdater node pricingUpdater on Host 10.180.85.16
details: [pid:10705, state:running]
}]
but if I try to run the same script via crontab I get:
Starting Oracle Communication Elastic Charging Controller 11.2.0.1 ...
so the utility is not started.
It seems that you are running the cron jobs with user which doesn't have permission to edit or create /home/eceuser/Muthu/details/Latest.txt file
I have created a cron job to start and stop instance at particular times.
I have set up amazon APIs against user ubuntu. saved script start.sh in home folder
#!/bin/bash
ec2-start-instances i-instanceID
I placed the job in cron tab.
0 18 * * 5 /home/ubuntu/scripts/dev/stop.sh
The script is exicuiting on specific times but the instances are not stopping/starting.
Can anyone suggest a way out.
I also tried setting up the same job in root user that also failed
You need to define which binary is executing the script. Hence, try with this:
0 18 * * 5 /bin/bash /home/ubuntu/scripts/dev/stop.sh
^^^^^^^^^
I have two cron jobs for importing image process into Database and scheduled that cron runs per two days once at server time 1 hour 2min. I need to check if the cron runs or not using shell script and kill that cron if the runs that cron already or after two days. Can you anybody guide me?
Example:
2 1 */2 * * cd /var/www/railsapp/book_app_v2 && /usr/local/bin/rake RAILS_ENV=production db:load_java_photo 2>&1 >> /var/www/railsapp/book_app/log/cron_book_photo.log
If I understand you right, you want to prevent cron overruns. Check out hatools, which addresses exactly that issue.
halockrun provides a simple and reliable way to implement a locking in shell scripts. A typical usage for halockrun is to prevent
cronjobs to run simultanously. halockrun's implementation makes it
very resilient to all kind of stale locks.
hatimerun provides a time-out mechanism that can be used from shell scripts. hatimerun can set multiple actions--signals to be
sent--on multiple timeouts.