I have written a "simple" shell-script (BASH) to monitor the logs of our Resin-applicationserver. Whenever Resin runs out of available heap-space, the script then tries to restart the Resin-server.
My problem is that my "autopilot"-script fails when it's run from crontab.
Here's what the script does:
1. Check available heap-space. If heap-space < 15%, then restart server.
2. I created a function to stop the server, which is called next in this event.
3. Next I verify if all processes are stopped. I cannot use the command "/etc/init.d/resin restart" because the server will sometimes take too long to stop (handling user sessions) and I cannot depend on the sleep-command in the init-script.
4. Next I try to start the server using this function:
5.Then again check for successful start. Retry when failed or exit when done.
Now, when run from commandline, this script works great.
When I execute the /etc/init.d/resin stop/start from commandline, it also works great.
But... when run from crontab, every 5 minutes, it can stop the server, but fails to start it again.
When run from crontab, it tries to execute "/etc/init.d/resin start" over and over again, without result. I know this, because I made the init-script mail me when it's called. There's no output at all, no errors in logging, nothing...
Do I need a special way to call the init-script? (Instead of just executing it)
One more problem for me is that we just acquired the company who runs this application and I am its admin. However, I only have a production-environment and cannot "experiment" too much.
I finally found out why things weren't working... I ran the env-command from crontab and did the same for root and found out that crontab's path was only /bin;/usr/bin. The init-script "inherited" these environmentsettings and couldn't find the Debian /sbin/start-stop-daemon. From there on, it was simple...
I finally found out why things weren't working... I ran the env-command from crontab and did the same for root and found out that crontab's path was only /bin;/usr/bin. The init-script "inherited" these environmentsettings and couldn't find the Debian /sbin/start-stop-daemon. From there on, it was simple...
Thanks guys!
We use SUSE SLES Linux at my office a great deal and I run into this issue a great deal. One of the things I find that helps is doing a sudo -c to run commands from crontab. It seems to apply the real user environment to the cron shell.
Hello all,
I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly.
My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
#!/bin/bash
#
# RAP configuration script
#
# Usage: ./rap.sh
#
# Requires: expect, tcl
#
# Script expects to find a file called rap.csv located in the same directory as the script. If the file is placed
# in a different directory, modify the custom entries section to specify the absolute... (8 Replies)
I encountered a problem on one of our database servers.
OS: CentOS 5.5 final
Kernel: 2.6.18-238.5.1.el5.028stab085.2 (OpenVZ kernel)
We wrote some DB-Start/Stop-scripts ("/db2/admin/scripts_dba/start_services.ksh" and ".../stop_services.ksh") to start the database instances. (Database... (1 Reply)
hi i have a script called test.sh. the content is ls >> crontest.txt.
if i run manually it's giving output.but if i scheduled in crontab it's not giving output.
crontab entry:
02 * * * * /sms5/SMSHOME/eds_sh/test.sh >> /sms5/SMSHOME/eds_sh/testfile/logfile 2>&1
I am using ksh.is there... (2 Replies)
OS is Ubuntu 8.04.3. When I run the command:
/usr/bin/syslogMailer < /etc/syslog.pipes/criticalMessagesFrom a bash shell it works and i receive an email as per the script however when run from crontab it does not work. Can anyone explain why and how to fix it?
/usr/bin/syslogMailer... (4 Replies)
Hi
I am a novice Linux/Perl user and am struggling to overcome what I am sure is a simple problem.
I am using a perl program to create a shell script daily containing between 10 and 30 "at -f" commands for the same day. Then I change the file attributes to allow the file to be executed. When... (2 Replies)
I am using Solaris 9. I wish to run my script every 1 minute inteval. Though i can run it using below entry in crontab.
* * * * /export/home/username/script/file_exist_&_run.sh
in short above script will check whether a specific file exist in a directory. If it found it will inovke another... (10 Replies)
Hi Folks,
Could you please suggest me how to run a shell script on a solaris env without using crontab. I am actually trying to write a shell script which will grep "WORD" in the logfile andd sends a email.Thanks in advance.
Thanks
Sandeep. (3 Replies)
Hi,
My system has added an entry to the cron:
--> crontab -l
0 00,12 * * * wall%rc.powerfail:2::WARNING!!! The system is now operating with a power problem. This message will be walled every 12 hours. Remove this crontab entry after the problem is resolved.
I have had an issue... (8 Replies)