How to kill a process automatically?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Archanak
    New Member
    • Sep 2006
    • 79

    How to kill a process automatically?

    Hi,

    I want to kill a process at 5.00 p.m .

    I tried using crontab.

    In crontab i gave like this:-

    17 00 * * * kill processid.(say 1234)

    but it is not killing the process at that time?

    how should i give in crontab?

    I don't have root permission.

    only sudoers permission i have.

    How sholud i do this?

    with regards

    Archana
  • diSangro
    New Member
    • Jan 2007
    • 69

    #2
    First of all you must be sure you have rights to kill pid you want, i.e.: you can only kill pid you launched unless you are root.

    Originally posted by Archanak
    Hi,

    I want to kill a process at 5.00 p.m .

    I tried using crontab.

    In crontab i gave like this:-

    17 00 * * * kill processid.(say 1234)

    but it is not killing the process at that time?

    how should i give in crontab?

    I don't have root permission.

    only sudoers permission i have.

    How sholud i do this?

    with regards

    Archana

    Comment

    • Motoma
      Recognized Expert Specialist
      • Jan 2007
      • 3236

      #3
      You should probably put some sort of error logging on the cron line, perhaps redirecting both stderr and stdout to a file.

      My initial thought is that the user cron is being run as doesn't have the kill program in its $PATH.

      Originally posted by Archanak
      Hi,

      I want to kill a process at 5.00 p.m .

      I tried using crontab.

      In crontab i gave like this:-

      17 00 * * * kill processid.(say 1234)

      but it is not killing the process at that time?

      how should i give in crontab?

      I don't have root permission.

      only sudoers permission i have.

      How sholud i do this?

      with regards

      Archana

      Comment

      • Archanak
        New Member
        • Sep 2006
        • 79

        #4
        Originally posted by Motoma
        You should probably put some sort of error logging on the cron line, perhaps redirecting both stderr and stdout to a file.

        My initial thought is that the user cron is being run as doesn't have the kill program in its $PATH.
        Hi,

        can u explain a bit more about this ?



        with regards
        Archana

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          Originally posted by Archanak
          Hi,

          can u explain a bit more about this ?



          with regards
          Archana
          The first part: tack on "> /var/log/cron.kill.log 2>>&1" (sans quotes) to the end of your cron script. This will redirect any errors to the file /var/log/cron.kill.log for you to analyze.

          What I think is happening is that the cron script A) unable to find the "kill" program, B) the cron script does not have permissions to kill the job, or C) the cron job isn't getting the right PID.

          Comment

          • Archanak
            New Member
            • Sep 2006
            • 79

            #6
            Originally posted by Motoma
            The first part: tack on "> /var/log/cron.kill.log 2>>&1" (sans quotes) to the end of your cron script. This will redirect any errors to the file /var/log/cron.kill.log for you to analyze.

            What I think is happening is that the cron script A) unable to find the "kill" program, B) the cron script does not have permissions to kill the job, or C) the cron job isn't getting the right PID.

            Hi,

            Do i have to include "> /var/log/cron.kill.log 2>>&1" in crontab file?
            I tried doing that but it didn't kill the script?

            i gave like this:-crontab -e

            18 22 * * * kill processid.

            I can't give sudo kill in crontab and i can't give password also.(I tried giving but didn't work)

            process id is taken correctly.

            I checked crin file in that it was given like ORPHAN (no passwd entry)

            I don't have root permission.

            what are the otherways so that i can stop process without root permissions?

            with regards

            Archana

            Comment

            • Motoma
              Recognized Expert Specialist
              • Jan 2007
              • 3236

              #7
              Originally posted by Archanak
              Do i have to include "> /var/log/cron.kill.log 2>>&1" in crontab file?
              I tried doing that but it didn't kill the script?
              Right, but what it will do is create a file in /var/log called cron.kill.log which will have your errors listed.

              If that file does not exists, change it to your home directory.

              Comment

              Working...