ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Crontab troubleshooting

    IT Discussion
    ubuntu 14.04 crontab
    3
    20
    3.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sparkum
      last edited by

      So if I run

       /home/sparkum/cron/job.sh
      

      I get the output that the service is running (which it isnt)

      if I run

       sh /home/sparkum/cron/job.sh
      

      it says

       /home/sparkum/cron/job.sh: 4: /home/sparkum/cron/job/sh: 5: not round
       starting service
      

      and then all is working....

      scottalanmillerS 1 Reply Last reply Reply Quote 0
      • S
        Sparkum
        last edited by

        Script I'm using is

         #!/bin/bash 
         service=replace_me_with_a_valid_service
        
         if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
         then
         echo "$service is running!!!"
         else
         /etc/init.d/$service start
         fi
        
        1 Reply Last reply Reply Quote 0
        • scottalanmillerS
          scottalanmiller @Sparkum
          last edited by

          @Sparkum said in Crontab troubleshooting:

          So if I run

           /home/sparkum/cron/job.sh
          

          I get the output that the service is running (which it isnt)

          if I run

           sh /home/sparkum/cron/job.sh
          

          it says

           /home/sparkum/cron/job.sh: 4: /home/sparkum/cron/job/sh: 5: not round
           starting service
          

          and then all is working....

          So something is wrong with your script, then. You need to fix the script so that it works properly before talking about scheduling it. Why is it giving bad output when run as intended?

          1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller
            last edited by

            Before we fix this, let's step back. What is the goal here, this does not feel like the right way to be approaching the problem.

            S 1 Reply Last reply Reply Quote 1
            • S
              Sparkum @scottalanmiller
              last edited by

              @scottalanmiller

              Simply to check if a service is running, if it is do nothing,

              If the service has stopped, to start it.

              scottalanmillerS 1 Reply Last reply Reply Quote 0
              • scottalanmillerS
                scottalanmiller @Sparkum
                last edited by

                @Sparkum said in Crontab troubleshooting:

                @scottalanmiller

                Simply to check if a service is running, if it is do nothing,

                If the service has stopped, to start it.

                Then why use a script rather than using an industry standard tool for that? Like having the system keep it running itself or using something built for this? Why reinvent the wheel?

                S 1 Reply Last reply Reply Quote 0
                • S
                  Sparkum @scottalanmiller
                  last edited by

                  @scottalanmiller

                  Simply chalk it up to me learning.

                  If you wouldnt mind throwing me in the right direction I'll be on my way haha

                  1 Reply Last reply Reply Quote 0
                  • scottalanmillerS
                    scottalanmiller
                    last edited by

                    Even if you do want to reinvent the wheel.... the OS has tools for that, too. You are at the mercy of things with service in their names. That's not good.

                    What OS are you on? /etc/init.d is deprecated.

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      Sparkum @scottalanmiller
                      last edited by

                      @scottalanmiller
                      Using Ubuntu 14.04

                      scottalanmillerS 1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller @Sparkum
                        last edited by

                        @Sparkum said in Crontab troubleshooting:

                        @scottalanmiller
                        Using Ubuntu 14.04

                        Oh okay, probably on the legacy system still then. In that case, what you are looking to do is better done with...

                        /etc/init.d/servicename status

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post