Results 1 to 10 of 11
HI ALL,
CAN ANY BODY HELP ME....?????
I HAVE WRITTEN A SHELL FILE THAT WILL STOP A JAVA (SOCKET PROGRAM)PORT LISTENER PROGRAM FROM CRON ON SCHEDULED BASIS.
BUT SOMETIMES IT ...
- 06-22-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 4
Shell file not running through crontab ???
HI ALL,
CAN ANY BODY HELP ME....?????
I HAVE WRITTEN A SHELL FILE THAT WILL STOP A JAVA (SOCKET PROGRAM)PORT LISTENER PROGRAM FROM CRON ON SCHEDULED BASIS.
BUT SOMETIMES IT IS NOT WORKING SOMETIMES IT WORKS.......
I AM POSTING THE SHELL FILE ---
After Stopping the shell file I have a shell file that will restart it...Code:StopPortReader6604.sh ---- #!/bin/bash PID=$(ps -ef | grep "Gprs6604PortReader" | grep -v grep | awk '{print $2}') echo $PID kill -9 $PID exit
both the shell file having permission like ---Code:StartPortReader6604.sh ----- #!/bin/bash cd /APP/app/src/net/gprs/ /APP/jdk1.5.0_08/bin/java -classpath .:/APP/jdk1.5.0_08/lib:/APP/jboss-4.0.5.GA/server/default/lib/jboss-j2ee.jar:/APP/jboss-4.0.5.GA/server/default/lib/ojdbc14.jar:/APP/jboss-4.0.5.GA/server/default/lib/log4j.jar:/APP/jboss-4.0.5.GA/server/default/lib/mail.jar:/APP/jboss-4.0.5.GA/server/default/lib/activation.jar:/APP/jboss-4.0.5.GA/server/default/lib/dom4j.jar:/APP/jboss-4.0.5.GA/server/default/lib/javax.servlet.jar:/APP/app/src/net/lib/appvts.jar com.etrans.vts.datacollection.app.utility.Gprs6604PortReader exit
both the shell file run through crontab after each hour. The entry for both the shell file in crontab -eCode:-rwxrwxrwx 1 root root 925 Jun 18 12:04 StartPortReader6604.sh -rwxrwxrwx 1 root root 550 Jun 18 12:33 StopPortReader6604.sh
It means cron invokes StopPortReader6604.sh and StartPortReader6604.sh for every 11th and 12th minute of an hour respectively.Code:11 * * * * /APP/app/cronjobs/net/StopPortReader6604.sh 12 * * * * /APP/app/cronjobs/net/StartPortReader6604.sh
The problem is sometimes it invokes correctly but sometime it does not.
Is it because I have mentioned #!/bin/bash at start of the shell file and the file having permission of Root????
Can anybody help me Please???? need suggestion........
Thanks,
TapobrataLast edited by devils casper; 06-22-2010 at 02:34 PM. Reason: added [code] ... [/code] tags.
- 06-23-2010 #2
Did you check /var/log/messages for reason?
- 06-23-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 4
According to ur suggestion I checked /var/log/messages. It shows such messages --
************************************************** ************************************************
Jun 23 03:28:33 localhost sshd(pam_unix)[3073]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:28:43 localhost sshd(pam_unix)[3103]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:28:53 localhost sshd(pam_unix)[3170]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:03 localhost sshd(pam_unix)[3206]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:13 localhost sshd(pam_unix)[3258]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:18 localhost sshd(pam_unix)[3318]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:23 localhost sshd(pam_unix)[3340]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:33 localhost sshd(pam_unix)[3363]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:37 localhost sshd(pam_unix)[3407]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:47 localhost sshd(pam_unix)[3446]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:29:57 localhost sshd(pam_unix)[3504]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:30:07 localhost sshd(pam_unix)[3555]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:30:12 localhost sshd(pam_unix)[3859]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 03:30:27 localhost sshd(pam_unix)[3903]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=oracle
Jun 23 04:02:25 localhost cups: cupsd shutdown succeeded
Jun 23 04:02:26 localhost cups: cupsd startup succeeded
Jun 23 04:19:34 localhost sshd(pam_unix)[20347]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=178.18.16.131 user=root
Jun 23 09:46:44 localhost remote(pam_unix)[12596]: session opened for user oracle by (uid=0)
Jun 23 09:47:15 localhost -- oracle[12596]: LOGIN ON pts/2 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 09:49:32 localhost su(pam_unix)[13728]: session opened for user root by oracle(uid=500)
Jun 23 09:56:54 localhost remote(pam_unix)[16358]: session opened for user oracle by (uid=0)
Jun 23 09:57:35 localhost -- oracle[16358]: LOGIN ON pts/4 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 09:58:19 localhost su(pam_unix)[17075]: session opened for user root by oracle(uid=500)
Jun 23 10:01:08 localhost remote(pam_unix)[18209]: session opened for user oracle by (uid=0)
Jun 23 10:01:43 localhost -- oracle[18209]: LOGIN ON pts/5 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 10:28:04 localhost remote(pam_unix)[28152]: authentication failure; logname= uid=0 euid=0 tty=pts/6 ruser= rhost=59.162.185.93.static.vsnl.net.in user=oracle
Jun 23 10:28:17 localhost login[28152]: FAILED LOGIN 1 FROM 59.162.185.93.static.vsnl.net.in FOR oracle, Authentication failure
Jun 23 10:30:51 localhost remote(pam_unix)[28911]: session opened for user oracle by (uid=0)
Jun 23 10:31:34 localhost remote(pam_unix)[29544]: session opened for user oracle by (uid=0)
Jun 23 10:32:04 localhost -- oracle[29544]: LOGIN ON pts/6 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 10:49:57 localhost remote(pam_unix)[3959]: session opened for user oracle by (uid=0)
Jun 23 10:51:09 localhost remote(pam_unix)[4485]: session opened for user oracle by (uid=0)
Jun 23 10:52:16 localhost telnetd[4822]: ttloop: peer died: EOF
Jun 23 10:53:03 localhost remote(pam_unix)[5148]: session opened for user oracle by (uid=0)
Jun 23 10:53:39 localhost -- oracle[5148]: LOGIN ON pts/3 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 10:53:46 localhost su(pam_unix)[5770]: session opened for user root by oracle(uid=500)
Jun 23 10:53:54 localhost remote(pam_unix)[5412]: session opened for user oracle by (uid=0)
Jun 23 10:54:35 localhost -- oracle[5412]: LOGIN ON pts/7 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 10:55:32 localhost su(pam_unix)[5770]: session closed for user root
Jun 23 10:55:44 localhost remote(pam_unix)[5148]: session closed for user oracle
Jun 23 11:00:39 localhost remote(pam_unix)[5412]: session closed for user oracle
Jun 23 11:01:52 localhost remote(pam_unix)[9127]: session opened for user oracle by (uid=0)
Jun 23 11:02:28 localhost -- oracle[9127]: LOGIN ON pts/3 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 11:03:23 localhost remote(pam_unix)[9720]: session opened for user oracle by (uid=0)
Jun 23 11:04:04 localhost -- oracle[9720]: LOGIN ON pts/7 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 11:05:03 localhost remote(pam_unix)[10335]: session opened for user oracle by (uid=0)
Jun 23 11:05:43 localhost -- oracle[10335]: LOGIN ON pts/8 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 11:52:27 localhost su(pam_unix)[27574]: session opened for user root by oracle(uid=500)
Jun 23 12:14:47 localhost remote(pam_unix)[3270]: session opened for user oracle by (uid=0)
Jun 23 12:15:22 localhost -- oracle[3270]: LOGIN ON pts/9 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:20:02 localhost su(pam_unix)[5306]: session opened for user root by oracle(uid=500)
Jun 23 12:25:10 localhost remote(pam_unix)[7000]: session opened for user oracle by (uid=0)
Jun 23 12:25:46 localhost -- oracle[7000]: LOGIN ON pts/10 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:27:33 localhost remote(pam_unix)[7820]: session opened for user oracle by (uid=0)
Jun 23 12:28:31 localhost remote(pam_unix)[8189]: session opened for user oracle by (uid=0)
Jun 23 12:29:06 localhost -- oracle[8189]: LOGIN ON pts/11 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:38:50 localhost sshd(pam_unix)[12030]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 12:39:05 localhost sshd(pam_unix)[12050]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=204.45.86.213 user=root
Jun 23 12:42:00 localhost remote(pam_unix)[12946]: session opened for user oracle by (uid=0)
Jun 23 12:42:33 localhost remote(pam_unix)[13100]: session opened for user oracle by (uid=0)
Jun 23 12:42:40 localhost -- oracle[12946]: LOGIN ON pts/12 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:43:05 localhost remote(pam_unix)[13276]: session opened for user oracle by (uid=0)
Jun 23 12:43:14 localhost -- oracle[13100]: LOGIN ON pts/13 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:43:45 localhost -- oracle[13276]: LOGIN ON pts/14 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 12:45:44 localhost remote(pam_unix)[14130]: session opened for user oracle by (uid=0)
Jun 23 12:46:37 localhost remote(pam_unix)[14578]: session opened for user oracle by (uid=0)
Jun 23 12:47:12 localhost -- oracle[14578]: LOGIN ON pts/15 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 12:51:48 localhost remote(pam_unix)[14578]: session closed for user oracle
Jun 23 13:10:43 localhost remote(pam_unix)[22579]: session opened for user oracle by (uid=0)
Jun 23 13:11:19 localhost -- oracle[22579]: LOGIN ON pts/15 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 13:11:31 localhost su(pam_unix)[23201]: session opened for user root by oracle(uid=500)
Jun 23 13:15:15 localhost su(pam_unix)[13728]: session closed for user root
Jun 23 13:15:25 localhost remote(pam_unix)[12596]: session closed for user oracle
Jun 23 13:16:09 localhost remote(pam_unix)[24707]: session opened for user oracle by (uid=0)
Jun 23 13:18:47 localhost remote(pam_unix)[25588]: session opened for user oracle by (uid=0)
Jun 23 13:19:22 localhost -- oracle[25588]: LOGIN ON pts/2 BY oracle FROM 59.162.185.83.static.vsnl.net.in
Jun 23 13:20:42 localhost su(pam_unix)[26586]: session opened for user root by oracle(uid=500)
Jun 23 13:56:45 localhost su(pam_unix)[23201]: session closed for user root
Jun 23 13:56:55 localhost remote(pam_unix)[22579]: session closed for user oracle
Jun 23 14:38:49 localhost remote(pam_unix)[21646]: session opened for user oracle by (uid=0)
Jun 23 14:39:28 localhost remote(pam_unix)[22056]: bad username []
Jun 23 14:39:38 localhost login[22056]: FAILED LOGIN 1 FROM 59.162.185.93.static.vsnl.net.in FOR , Authentication failure
Jun 23 14:41:51 localhost remote(pam_unix)[22924]: session opened for user oracle by (uid=0)
Jun 23 14:45:28 localhost remote(pam_unix)[24155]: session opened for user oracle by (uid=0)
Jun 23 14:45:57 localhost remote(pam_unix)[24357]: session opened for user oracle by (uid=0)
Jun 23 14:46:03 localhost -- oracle[24155]: LOGIN ON pts/16 BY oracle FROM 59.162.185.93.static.vsnl.net.in
Jun 23 14:54:26 localhost remote(pam_unix)[12946]: session closed for user oracle
************************************************** ************************************************** *
I am unable to understand this msg. Please help me out.
- 06-23-2010 #4
there are no log for cron job. please send log files after crontab is not working or crash.
- 06-23-2010 #5Just Joined!
- Join Date
- Jun 2010
- Posts
- 4
I have checked the log file for cron jobs in /var/log/ . It shows like this ----
Jun 23 16:45:01 localhost crond[5021]: (root) CMD (/APP/app/cronjobs/net/run_sp_journey.sh)
Jun 23 16:45:01 localhost crond[5008]: (root) CMD (/APP/app/cronjobs/net/run_etlreport.sh)
Jun 23 16:45:01 localhost crond[5024]: (root) CMD (/APP/app/cronjobs/net/run_sms_http.sh)
Jun 23 16:45:01 localhost crond[5032]: (root) CMD (/APP/app/cronjobs/net/run_GprsDataParser.sh)
Jun 23 16:46:01 localhost crond[5556]: (root) CMD (/APP/app/cronjobs/net/run_gps2.sh)
Jun 23 16:46:01 localhost crond[5562]: (root) CMD (/APP/app/cronjobs/net/run_gps1.sh)
Jun 23 16:46:01 localhost crond[5565]: (root) CMD (/APP/app/cronjobs/net/run_homepg_final.sh)
Jun 23 16:47:01 localhost crond[5894]: (root) CMD (/APP/app/cronjobs/net/StopNewGprsPortReader6688.sh)
Jun 23 16:48:01 localhost crond[6240]: (root) CMD (/APP/app/cronjobs/net/run_gps2.sh)
Jun 23 16:48:01 localhost crond[6241]: (root) CMD (/APP/app/cronjobs/net/StartNewGprsPortReader6688.sh)
Jun 23 16:48:01 localhost crond[6243]: (root) CMD (/APP/app/cronjobs/net/run_gps1.sh)
Jun 23 16:48:01 localhost crond[6248]: (root) CMD (/APP/app/cronjobs/net/run_homepg_final.sh)
Jun 23 16:50:01 localhost crond[7011]: (root) CMD (/usr/lib/sa/sa1 1 1)
Jun 23 16:50:01 localhost crond[7014]: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --conf
cache-file /var/lib/mrtg/mrtg.ok)
Jun 23 16:50:01 localhost crond[7016]: (root) CMD (/APP/app/cronjobs/net/run_hindalco_sp_origin_dest.sh)
Jun 23 16:50:01 localhost crond[7029]: (root) CMD (/APP/app/cronjobs/net/pkg_sms.sms_alert.sh)
Jun 23 16:50:01 localhost crond[7033]: (root) CMD (/APP/app/cronjobs/net/run_sms_http.sh)
Jun 23 16:50:01 localhost crond[7035]: (root) CMD (/APP/app/cronjobs/net/run_RFID_Data_Process.sh)
Jun 23 16:50:01 localhost crond[7037]: (root) CMD (/APP/app/cronjobs/net/run_GprsDataParser.sh)
Jun 23 16:50:01 localhost crond[7022]: (root) CMD (/APP/app/cronjobs/net/run_gps2.sh)
Jun 23 16:50:01 localhost crond[7048]: (root) CMD (/APP/app/cronjobs/net/run_gps1.sh)
Jun 23 16:50:01 localhost crond[7049]: (root) CMD (/APP/app/cronjobs/net/run_homepg_final.sh)
Jun 23 16:50:01 localhost crond[7050]: (root) CMD (/APP/app/cronjobs/net/boc_sms_alert.sh)
Jun 23 16:50:01 localhost crond[7052]: (root) CMD (/APP/app/cronjobs/net/run_sp_refresh_entity_data.sh)
Jun 23 16:50:01 localhost crond[7053]: (root) CMD (/APP/app/cronjobs/net/run_Tisco_Card_Data.sh)
Jun 23 16:50:01 localhost crond[7066]: (root) CMD (/APP/app/cronjobs/net/run_sp_journey.sh)
Jun 23 16:51:01 localhost crond[7471]: (root) CMD (/APP/app/cronjobs/net/StopNewGprsPortReader6789.sh)
Jun 23 16:52:01 localhost crond[7755]: (root) CMD (/APP/app/cronjobs/net/run_gps2.sh)
Jun 23 16:52:01 localhost crond[7761]: (root) CMD (/APP/app/cronjobs/net/run_gps1.sh)
Jun 23 16:52:01 localhost crond[7768]: (root) CMD (/APP/app/cronjobs/net/run_homepg_final.sh)
Jun 23 16:52:01 localhost crond[7775]: (root) CMD (/APP/app/cronjobs/net/GprsSwipeTerminalReader.sh)
Jun 23 16:52:01 localhost crond[7780]: (root) CMD (/APP/app/cronjobs/net/StartNewGprsPortReader6789.sh)
Jun 23 16:54:01 localhost crond[8665]: (root) CMD (/APP/app/cronjobs/net/run_gps2.sh)
Jun 23 16:54:01 localhost crond[8670]: (root) CMD (/APP/app/cronjobs/net/run_gps1.sh)
Jun 23 16:54:01 localhost crond[8674]: (root) CMD (/APP/app/cronjobs/net/run_homepg_final.sh)
(END)
There is no error msg..
- 06-23-2010 #6
Yes no error messages in log file. So we shall wait a cronjob crash
- 06-23-2010 #7
It could be a number of things at this point and judging from the info you gave.
For example:
This will go wrong when there's not exactly one process of Gprs6604PortReader... some error where the stop scripts doesn't work but the start script does (or vice versa), that may cause such a situation to occur.Code:PID=$(ps -ef | grep "Gprs6604PortReader" | grep -v grep | awk '{print $2}') kill -9 $PID
If I where you, I'd try to verify 1) if the script is actually running and 2) what the values of the variables are. I'd also include some self-test for the script, before it runs actual commands on the system.
Of course, the RESULT variable will screw up if more than one value of PID is found, but I'm too lazy to write the code that makes everything iterate through arrays...Code:#!/bin/bash #StopPortReader6604.sh ---- # Never mind my layout, I like using loads of whitespace :p # Log for debugging purposes LOGFILE="/tmp/stop.log" # Grep the process ID's PID=$( ps -ef |\ grep "Gprs6604PortReader" |\ grep -v grep |\ awk '{print $2}' ) # Now test if [ ! $PID ] # If no process is found then RESULT="process not found" else # For every value in PID (may be multiple) for i in $PID do # Kill the process, kill dash nine! # And record the results, just in case kill -9 $i \ && RESULT="succes" \ || RESULT="fail" done fi # DEBUG cat <<EOF>> $LOGFILE ################################# $0 ran at `date` PID is ${PID:-empty} RESULT is ${RESULT:-empty} EOF exit 0
But at least you'll know whether your script ran, including the time. Also, you'll know the value of PID (if any) and the RESULT
Can't tell an OS by it's GUI
- 06-23-2010 #8
seems to me that it would be better to spend time figuring out why you need to restart your application on a scheduled basis
- 06-24-2010 #9Just Joined!
- Join Date
- Jun 2010
- Location
- Mumbai
- Posts
- 5
- 06-24-2010 #10
i could be way off, and this may not help at all. if you are firing those scripts off at different intervals and they are not firing off correctly, maybe you should try a different approach,.
when i write a bash script that is dependent on another command or process to complete i use the $! variable. it represents the PID of the last command called, so if you used:
the script would halt until that process had complete. if you called your stop script, then gave a wait like that, to fire off the start script it may solve your problem.Code:$COM_PID=$! wait $COM_PID
just a suggestion, like i said i could be way off...linux user # 503963


Reply With Quote
