Activating or kicking off a shutdown hook?

The Java 1.3 SDK API writes the following about shudown hooks:
The Java virtual machine shuts down in response to two kinds of events:
The program exits normally, when the last non-daemon thread exits or when the exit (equivalently, System.exit) method is invoked, or
The virtual machine is terminated in response to a user interrupt, such as typing ^C, or a system-wide event, such as user logoff or system shutdown.I was wondering whether any of these events can be generated from a batch file. The reason behind this is that i would like a Java program to be shutdown remotely and not having to be in front of the computer pressing CTRL+C.
Thank you in advance.

I was wondering whether any of these events can be
generated from a batch file. The reason behind this is
that i would like a Java program to be shutdown
remotely and not having to be in front of the computer
pressing CTRL+C.In a unix environment the process is shut down with a signal. As an alternative to being generated from the keyboard these can be generated by the "kill" command.

Similar Messages

  • Shutdown hooker, how does it work?

    hello All:
    I am writting a Java service that might crash for unknown reasons. As a failover mechanism, i was thinking to use shutdown hook to do house cleaning work such as closing db connection, notifying the client of this service, etc.
    However, people point it out that #1, inside shutdown hook it is ok to close db connection, but notifying client won't work; #2, shutdown hook is not reliable and likely not be called in the first place when the system crashes. Like that in the Linux env, it can be killed by "kill" or "kill -9", the impact on the service can be different.
    Anyone can make a comment about the above statements? And what's the best options in a crashing sceanario?
    Thanks,
    Sway

    mlk wrote:
    pierrot_2 wrote:
    Right, if I knew I had to pucker up, I'd put my head between my legs first... but there's no way to tell. Is there anything else you can use to moniter external conditions -- a backup battery?Some UPSes can inform the host that is has lost power and should shut down (but that is not a Java problem but a general OS/server setup issue). But you can't guard against everything (kill -9, running on a VM and someone killing your VM in that). The best you can do is attempt to make sure that you leave the world in as sane state as possible (for example good use of transactions) and make sure your monitoring solution works.Best example of that I ever encountered was a computer with 2 independent power supplies hooked up to an extension cable with a splitter, going into a single UPS and a single wall outlet.
    Someone tripped over the cable, pulling it out of the UPS outlet, thus killing the power to the machine past the point where the UPS is set to guard against power failure, and due to the idiotic arrangement which compromised the very reason (failsafe) there were 2 power supplies causing the machine to turn off.
    No amount of software can guard against such stupidity, yet we were told to modify the software so that it would continue to run in case of power failure (not joking, really happened).
    After much debate we modified it to constantly monitor and document its own state so it could restart where it left off before a power failure.

  • Getting kicked off of ichat

    Okay, I am getting kicked off of ichat without even knowning that I am offline. I am hooked up through a linksys wireless router wrt54g model. Also, I ALWAYS get an error message when trying to connect to videochat. any help on this would be great!
    Thank you in advance.

    Hi Trenchtown,
    Welcome to the Apple Discussions
    If you mean that when you have logged in to the AIM servers that you get silent drops in connection...
    (iChat looks like it is connected but Buddies report you look off line and during chats the Texts. stop coming and they don't get yours)
    Then go to the Airport icon in the Menu Bar if you have it there and Select Signal Robustness.
    8:22 PM Wednesday; April 11, 2007

  • SCEP 2012 clients kicking off random scans

    We have an SCCM 2012 environment with SCEP 2012 recently deployed. We have a policy in place that does weekly full scans on Tuesdays at 12AM.  The client machines are 64 bit Windows 7.  We are seeing some random computers kicking off Full scans
    at various points in the day.  We thought that initially there were viruses on these machines and that was causing the scans, but according to the EP console, they do not have any type of virus or malware.
    Any ideas?

    Here is the way MS does such things. (Update works this way too) It is STUPID, of course, but then "SMART" is not a word that fits Microsoft very well. Just look at Windows 8 for an example or to the fact you can't even find a simple link to the
    SCEP client for what ever happens to be the latest greatest version.
    As for the auto scanning, it will occur REGARDLESS of the time set shortly after you start your PC if it was not able to do it at the appointed time. So if it is set for 12am, and if the system, for whatever reason was not on, it will kick off shorty after
    it is booted, REGARDLESS of the current time. (It is supposed to wait until the system is idle, but MS uses lack of keyboard or mouse action to decide if a system is active instead of actually looking to see if its. For example watching a movie. MS would say
    after five minutes, it is inactive, then run the scan, screen save, update, or whatever. Maybe you were just reading a long email, letter, or article online, doesn't matter MS will kick off the scheduled event. Of course this will cause problems for the movie
    etc, but MS won't care. Bottom line is if the MS AV is doing its job, or anyone's Av for that matter, and was installed on a 100% clean PC, then one should NEVER need to do a blind system scan. Common sense really. Of course MS AV is not very good at preventing
    the more destructive of the evils out there such as the Ransomewares and things like the ASK or the Google toolbar or the many fake "fix your PC" popups that are out there etc. etc.
    Best just to keep it disabled.
    Ralph

  • Eating CPU - "Installer" process periodically kicks off - Need Help

    Periodically, a process called Installer kicks off and eats up CPU and System memory and brings my system to a halt.  I can remove it from the
    Activity Monitor and everything is OK, but after a while it comes back.
    Does anyone know what this is and how I can get rid of it?
    Here is a screenshot of the process

    From what I understand, if you are sure you looked in the correct directory and did not find the launchd.conf then you should be safe to remove the other files. Make sure you have backups of your data before removing the files in case something does go wrong.
    I have not had this issue so I can't speak from experience. I have just seen a number of posts on this on the site. @thomasareed knows more about this issue and can tell you more about it.
    The /private/etc/ directory is from the top level directory of the hard drive so make sure that is the area that you looked in. You should be able to go up to the finder menu, select go, select go to folder and just paste the path /private/etc/ into the go and it should open the proper directory and then look to see if launchd.conf is listed. If not, you should be ok to remove the other files.

  • Logger disabled in shutdown hook thread

    Hi, all,
    In a shutdown hook thread, i want to keep a log using jdk1.4's logging class as following:
    public void run(){
    synchronized(this){
    logger.info("System Shutdown");
    But the logger does not work. Does anybody have the idea?
    I create the logger with the following:
    FileHandler fh = new FileHandler("MyLog.log");
    fh.setFormatter(new CCXmlFormatter());
    logger=Logger.getLogger("MyLog");
    logger.addHandler(fh);

    Please accept my appology for the off subject materiel. I just finished writing this and do not want to edit...
    There is a design problem in the MemoryHandler class in that the close() method does not invoke push() as might be expected because most close() methods do flush buffers. This problem is exacerbated by the fact that LogManager registers a shutdown hook that closes all handlers. The log manager shutdown hook also does not invoke push() for memory handlers. Thus it is incumbent upon the user to invoke push() prior to shutting down. It would be natural to do this in a shutdown hook inside of a configureLogger() method. For example,
    private static Logger configureLogger() {
    Logger logger = Logger.getLogger("com.javarules");
    logger.setLevel(Level.ALL);
    try {
    target =new FileHandler("%t/javarules.log",20000,1);
    target.setFormatter(new SimpleFormatter());
    } catch(IOException e) {
    e.printStackTrace();
    System.exit(1);
    memoryHandler = new MemoryHandler(target,
    2000,
    Level.SEVERE);
    Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() {
    memoryHandler.push();
    logger.addHandler(memoryHandler);
    logger.setUseParentHandlers(false);
    return logger;
    The problem with this is that shutdown hooks are a bunch of unstarted threads that the JVM runs concurrently. There is no guarantee this shutdown hook will run before the log manager closes the handler. (In my experience, the log manager shutdown hook runs first most of the time.)
    Closing a memory handler does two things. The target handler is closed and the memory handler level is set to OFF, which means that when your shutdown hook runs, nothing is published and the push() method completes normally. In single-threaded applications memory-Handler.push() can be invoked at the bottom of the main method. GUI applications should invoke it in AWTExceptionHandler (or whatever you call your top-level exception handler) as well as the windowClosing (WindowEvent e) method.
    There is actually a larger design issue than not being able to invoke push() in a shutdown hook. Should the LogManager class be registering a shutdown hook that invokes reset()? The API docs for that method read as follows.
    Reset the logging configuration.
    For all named loggers, the reset operation
    removes and closes all Handlers and (except
    for the root logger) sets the level to null.
    The root logger's level is set to Level.INFO.
    Bug Id 4682478 addresses this question, but misses the mark because it suggests an ordering (or reordering) of shutdown hooks. The evaluation correctly notes that it �is dangerous to rely on ordering of shutdown operations.� As noted above, shutdown hooks are a bunch of unstarted threads that a JVM starts and runs concurrently. They are not and never will be ordered. See java.sun.com/j2se/1.3/docs/guide/lang/hook-design.html for a discussion. The question, however, is not the fact that shutdown hooks are unordered. The question is should the log manager be closing handlers. In other words, should LogManager be registering a shutdown hook at all? If the answer is yes, the only plausible explanation is the push() method in a memory handler, which explains why I began this section with a discussion of that method. There is no documentation to support this theory (which in and of itself is a problem), but it is at least possible that the Cleaner thread (which is the name of the shutdown hook registered in LogManager) is designed precisely so that application programmers would not use the logging API in a shutdown hook. Logging one or two messages in a shutdown hook would not be a problem, but invoking push() for a memory handler that has thousands of log records that must be both localized and formatted could be a problem. As noted in the addShutdownHook(Thread hook) method:
    Shutdown hooks should... finish their work
    quickly. When a program invokes exit the
    expectation is that the virtual machine will
    promptly shut down and exit. When the virtual
    machine is terminated due to user logoff or
    system shutdown the underlying operating
    system may only allow a fixed amount of time
    in which to shut down and exit. It is there-
    fore inadvisable to attempt any user
    interaction or to perform a long-running
    computation in a shutdown hook.
    I think this warning should suffice, however, and that the logging API should be usable in a shutdown hook. At a bare minimum the LogManager class should document the rationale for making the logging API unavailable during shutdown.

  • Kick off time parameter

    Hello Guys,
    Our users are being kicked off from the system once after 8 years. exatly at the end of 8 hours time, they could be doing something, nevertheless they get kicked off.
    i want to make this parameter to 10 hours, can you please let me know which parameter needs to be changed?
    Best regards.
    Lata.

    Hi , This parameter is not the correct parameter because we have this parameters value as 2700 secods which means its on 45 seconds.
    I guess this parameter is only to control session.
    What i am looking for is a parameter that controls your login, despite of being active continuously.
    thanks and regards,
    Lata.

  • Background processes on SAP BW Production stall - kicked off via UC4

    All,
    We have the following issue; there 6 background processes available on the BW server. The UC4 (external) scheduler kicked off 3 jobs that in turn was kicking off 3 process chains which were trying to kick off 10  background processes. The result was that 6 background processes were kicked off, seemed to be active (in sm37), but actually stalled (they were not doing anything), it was like they ended up in a deadlock. Normally one would expect the processes to run according to the mechanism that when there are no background processes available, to wait. My guess is that because they were initiated by an external scheduler and demanded more than the total available background processes that mechanism did not work. Has anyone encountered this problem before? And knows why it happens?
    Regards, Meindert

    Hi Meindert,
    If I recall correctly I remember having seen this before as well, and then the root cause actually was the way the process chains work. There was (is?) some dependency on free batch processes in the initialization phase of the process chain which lead to hanging processes if you started a few process chains at the same time and there are not enough free batch processes available.
    I believe this is internal to SAP so probably not caused by scheduling the chains externally, however your external scheduler could maybe take the number of free batch processes into account. I do not know your external scheduler well enough to explain it for that product, I do know how I would handle it with CPS: I'd use queueing to make sure that there are enough free batch processes available, or I would let it monitor the number of free batch processes on the system and if that would become too low, I'd temporarily hold new process chains that needed to start. The chosen option would depend on the priorities of the processes involved, to make sure that the processes with the highest priorities can always start and always have batch processes available.
    Regards,
    Anton.

  • Kicked off network at night and cant reconnect til...

    Okay so almost every night (usually around midnight but sometimes earlier) at least one of our computers gets kicked off the network even though the all the lights on the hub are on and I can see its still active on the computer. Even my friend's xbox get kicked off. When I try to reconnect the computers it says windows was unable to connect, and troubleshooting suggests I'm not in range or that i should checked my adapter's settings. I checked and everything seemed fine. Also ran antivirus and whatnot, but found nothing.
    Im not a very computer smart person so I really dont know what's wrong. Im posting it here mainly because I already have an account, Bt is my internet provider and I have a homehub, and a friend said Bt could be kicking me off  (but he has a grudge against bt after having an argument with techsupport on the phone, and blames most computer problems on them).
    Please help, or if this is the wrong forums point me elsewhere. Thanks. 

    Sorry I took so long to reply, been busy.
    I changed the channel, still getting kicked off at night. And we've had bt broadband for over a year now I think so...
    Also I should probably mention we do have other issues that I guess are similar.
    -If downloading a large file the computer doing so gets kicked off the network and usually cant re-connect for half a day. (very annoying)
    -I don't think the speeds are what they should be but we live in the countryside(ish) and its nowhere near unbearable.
    -When me or my sister load up the game team fortress2 the hub resets.(haven't tried in the last few weeks)
    -Sometimes at night after being kicked I see a CT homehub as well as my BT homehub and openzone on the connection list.
    -Router resets once or so a week.
    Any ideas?
    Sorry for the bother.

  • High level of I/O (large write and then zpool scrub cron kicked off) causin

    I have a test server running Solaris x86 patched up to current(April 15th) with pca. My FC adapter is a LSI 929 card (using LSI provided Solaris 10 driver called itmpt). My storage is an old Storagetek 5000 series (I think 5100).
    I have been testing ZFS stuff on this before implementing in production environments, all Sparc systems with internal disks or more recent FC arrays. Over the weekend a backup that dumps about 50 GB of data onto the Sol10 x86 machine lasted long enough to still be running when the zfs scrub cron I created kicked off. I wake up to find one pool completely offline with 4 devices showing unavailable and a string of messages about i/o request timeouts. A reboot and scrub with no other activity seems to have fixed it, no errors reported and it stopped saying I should nuke everything and start over (I hate that almost always wrong advice).
    Will ZFS on FC always be suceptable to this kind of problem? So far I have not seen this on SATA/SAS but maybe I'm lucky. This makes me wary of scrubbing on production systems.

    961262 wrote:
    The used tables:
    Table 1: 312 col, 12,248 MB, 11,138,561 rows, avg len 621 bytes
    Table 2: 159 col, 4288 MB, 5,441,171 rows, avg len 529 bytes
    Table 3: 118 col, 360MB, 820,259 rows, avg len 266 bytes
    The FTS has improved as expected. With 5 physical drives in a RAID0, a performance of
    420MB/s was achieved.
    In the write test on the other hand we were not able to archieve any improvement.
    The CTAS statement always works with about 5000 - 6000 BLOCK/s (80MB/s)
    But when we tried running several CTAS statements in different sessions, the overall speed increased as expected.
    Further tests showed that the write speed seems to depend also on the number of columns. 80MB/s were only
    possible with Tables 2 and 3. With Table 1, however only 30MB/s were measured.
    If multiple CTAS can produce higher throughput on writes this tells you that it is the production of the data that is the limit, not the writing. Notice in your example that nearly 75% of the time of the CTAS as CPU, not I/O.
    The thing about number of columns is that table 1 has exceeded the critical 254 limit - this means Oracle has chained all the rows internally into two pieces; this introduces lots of extra CPU-intensive operations (consistent gets, table access by rowid, heap block compress) so that the CPU time could have gone up significantly, resulting in a lower throughput that you are interpreting as a write problem.
    One other thought - if you are currently doing CTAS by "create as select from {real SAP table}" there may be other side effects that you're not going to see. I would do "create test clone of real SAP table", then "create as select from clone" to try and eliminate any such anomalies.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • I am having trouble connecting to my network all of a sudden. It is not an issue with the service/router. I keep getting kicked off and getting a ! in my airport... anyone know what's up with this?

    I am having trouble connecting to my network all of a sudden. I am able to connect to other networks but not my own. It is not an issue with the service/router because other devices connect fine. I keep getting kicked off and getting a ! in my airport. Last time it happended I called apple and the suggested I wipe my HD and reinstall everything. I did and it did not work. One day I turned my laptop on and it connected no problem. Now it has kicked me off again. I tried resetting my IP address but that does not work either! Has anyone had this problem?

    Try this:
    Apple menu / System Preferences / Network.
    Click Location: and select Edit Locations..
    Click + (plus sign), and enter a name for the new location - anything will do.
    Apply this.

  • TS1717 I had to restore my itunes library however everytime I try to go to my podcasts I am kicked off of Itunes with a send/dont send error report I can acess podcasts only while syncing ipod

    I have been having trouble getting into my podcasts after restoring my itunes library to an earlier library, every time I select podcast i am kicked off itunes with an error send/dont send pop up however I can acess the podcasts when sinking my ipod only

    Hello there, danbucfan.
    It seems that you were referred to us from the very article that provides steps for troubleshooting your issue. Although they may seem extensive, these steps will help pinpoint where the issue lies:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    If you continue to get the error, please feel free to provide the exact error message, to see if that sheds further light on what your issue may be.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • How do I get my ipod back on the school wifi after being kicked off?

    My school has password locked wifi, which every student knows the password to. Every so often, they kick people's iPod's off the wifi and it won't ever connect. Not during school, not football games or basketball games, not ever again. It really ticks me off because my iPod was kicked off today. I don't get on a lot during school but I do tweet and facebook during ball games. Is there a way to override/avoid the block? Could I maybe reset the iPod or the network settings? Or change something in the settings that'll let me back in? Thanks.

    There is nothning you can do on your end unless you want to purchases a device like this
    Verizon Wireless - Mobile Broadband -
    AT&T Mobile Hotspot MiFi Liberate - Graphite Mobile Hotspot from AT&T

  • I have an IPad 1.  I keep getting kicked off the site and back to the start page. any ideas why?  Thank you.

    I have an IPAD 1.  I keep getting kicked off a site and back to the start page.  Any one know why and how can I fix it?  Thank you.

    Try this...
    Close All Open Apps...  Perform a Reset... Try again...
    Reset  ( No Data will be Lost )
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430

  • Macbook Pro 10.6.8 - why am I kicked off internet (wired and wifi) every 5-10 mins? All was fine before.

    Macbook Pro 10.6.8, 2 Ghz intel core i7 - --- Why am I kicked off internet (wired and wifi) every five-ten minutes?
    All was working fine last time I was using this same wireless and cable... about two weeks ago. Solution is the restart constantly. Or to use System Preferences and do "diagnostics" and somehow – sometimes – that reestablishes the connection.
    Is there some  kind of hard reset I should do?
    Thank you in advance for any advice!
    Jane in Haiti

    Check the time and date is correct and updating with Apple's time servers.
    WiFi, Internet problems, possible solutions
    WiFi security issues, at home and WiFi hotspots

Maybe you are looking for

  • Unable to connect to internet or print wirelessly on Boot Camp with Windows 7

    I recently installed Boot Camp and Windows 7 on my Mac Book Pro with no problems. A month later, I am unable to connect to internet or print wirelessly. It states that I am connected to my router. When I trouble shoot, it cannot find the problem. My

  • Looking for a good note taking app: Are there new features for the Notes app in iOS6?

    Hi, I've read that the Notes app with Mountain Lion will be available for OS X as well, and I was wondering if there will be any significant updates to the Notes app coming in iOS 6? The Notes app in Mountain Lion supports, as far as I know, text for

  • After 10.4.6 upgrade, sound doesn't work with certain apps.

    Hi, I upgraded recently to 10.4.6 and I've noted that there's no sound at all in certain applications. At the beginning, some games didn't work: Age of Empires II, Age of Mythology and Doom (curiously, I can hear music but no sounds in all of them).

  • Strange file in trash that won't go away?

    I have a strange file that appeared in my Trash the other day. I tried to empty the trash multiple times, but it won't go away. Secure empty trash doesn't help, as it just gets stuck. Double-clicking on the file, getting info on the file, or dragging

  • HS-23 silent when used with N73

    I just got a N73 from Vodafone which was packaged with a HS-23 headset. With this headset I use the silent profile but it seems that for incomming calls the ringtone cannot be heard in the headset as I would expect :-( If I change the profile setting