Hey Linux Sysadmin, I Got An Easy One

Matthew,

I have a process on Fedora 8, let’s call it sslexplorer (namely because that’s what it is.) I want to run a cron job every five minutes to make sure it’s running.

I type in crontab -e
*/5 * * * * “/etc/init.d/sslexplorer start” >/dev/null 2>&1

Is this correct? Are my quotes needed? Should I write a script that queries sslexplorer status and only starts it if it’s stopped?

Matthew,

I have a process on Fedora 8, let’s call it sslexplorer (namely because that’s what it is.) I want to run a cron job every five minutes to make sure it’s running.

I type in crontab -e */5 * * * * “/etc/init.d/sslexplorer start” >/dev/null 2>&1

Is this correct? Are my quotes needed? Should I write a script that queries sslexplorer status and only starts it if it’s stopped?

If so, how much would it cost to have you write such a script for me? I’ll swap names with you on Sam’s baby, so he can name it Matthew Stephen Graber…

Thanks Weed

8 thoughts on “Hey Linux Sysadmin, I Got An Easy One”

  1. Comments

    1. Userspace processes should not be run from /etc/init.d, only those things which are required when the machine boots up. Put it into your home directory somewhere. I tend to use /home/mbarnson/bin and add that to my $PATH.
    2. If I wanted it to run every five minutes, I’d set that first field as 0,5,10,15,20,25,30,35,40,45,50,55 rather than */5 because the */5 syntax is ONLY honored on Linux, while the longer syntax is recognized on every UNIX variant.
    3. The quotes are not necessary for this command, as you don’t have any spaces in the command you’re running (spaces between command and arguments are fine). It will parse fine without them. However, if you wish to use them, they won’t hurt. All they do is tell the shell interpreter to do variable substitution within the quotes, and perform escapes on any strings that need it, like spaces, reserved keywords, etc.
    4. If sslexplorer is supposed to run when the machine boots, you would be better off to create it as a legitimate daemon with an appropriate symlink to the runlevels where it should execute. If it absolutely must restart when it dies, add it as an init-controlled service via /etc/inittab (man inittab for details). Or you could wrap a monitoring daemon around it as a startup daemon, which is like 5 lines of code.

    To sum up, if this is a program that needs to be running all the time, add it as a full-fledged initscript that honors stop, start, and restart commands, or else put it directly under the control of init so that it will respawn if killed (like the individual TTYs do). If it truly needs run only intermittently, go ahead and run it under cron.


    Matthew P. Barnson

    1. SSL Explorer

      SSL Explorer has a nice init script. It is supposed to start at boot. I just want to make sure it restarts upon crash.

      So how do I put it under the control of init or do the monitoring daemon thingy?

      My $.02 Weed

      1. Copy of the init script?

        I’d need a copy of the init script to suggest modifications. Kind of tough if I don’t know how it starts or where it writes to.


        Matthew P. Barnson

  2. Naming Rights

    I like how the naming rights of my future child are up for barter. That’s fun.

    1. Thread…

      I suspect Sam meant to post in another thread, and even there, he may have wanted to Create A New Blog Entry rather than add a new comment…

      And, dude, if you put “Matthew” anywhere in the name of your son, I will wire you money via Paypal 😉


      Matthew P. Barnson

      1. See Above

        My placement was correct. See Weed’s comment above about swapping naming rights as possible barter for your coding services.

        1. I think he edited it

          I think he edited his blog entry after I replied. I look stupid enough already, I don’t need other people helping me along!


          Matthew P. Barnson

          1. Nope

            Sorry, it was there the whole time. And no abusing sysadmin powers to “create” a revision that wasn’t there….

            Sam, if Stephen is in the name of your son, I will buy him bonds every year until he turns 18. And unlike Matthew, if your child ends up missing its penis, you can still use Stephanie!

            My $.02 Weed

Comments are closed.