• Running something every minute

    From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Wed Apr 7 08:27:00 2021
    From Newsgroup: alt.os.linux.ubuntu

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    --
    Michael F. Stemper
    Isaiah 10:1-2
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Anssi Saari@as@sci.fi to alt.os.linux.ubuntu on Wed Apr 7 23:03:57 2021
    From Newsgroup: alt.os.linux.ubuntu

    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Well, if your script dies due to some error condition, then with option
    1 it stays dead until you reboot.

    On the other hand, if you run it with cron every minute then it runs for
    sure. And if there's an error then you get an email once a minute about
    it...

    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From gamo@gamo@telecable.es to alt.os.linux.ubuntu on Thu Apr 8 13:54:59 2021
    From Newsgroup: alt.os.linux.ubuntu

    El 7/4/21 a las 22:03, Anssi Saari escribió:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Well, if your script dies due to some error condition, then with option
    1 it stays dead until you reboot.

    On the other hand, if you run it with cron every minute then it runs for sure. And if there's an error then you get an email once a minute about
    it...


    Well in Ubuntu desktop you are not emailed in option 2, but anyway I
    would chose the option 1 maybe because it's more transparent and you
    could modify it, in example a 'sleep 60' is not exactlly once per minute because the task takes time and so on...

    --
    http://gamo.sdf-eu.org/
    perl -E 'say "Code could contain bugsh";'
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Andrei Z.@no-email@invalid.invalid to alt.os.linux.ubuntu on Thu Apr 8 15:43:11 2021
    From Newsgroup: alt.os.linux.ubuntu

    Michael F. Stemper wrote:
    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Repeat a command every x interval of time in terminal? - Ask Ubuntu https://askubuntu.com/questions/430382/repeat-a-command-every-x-interval-of-time-in-terminal

    How To Repeat A Command Every X Seconds On Linux - Linux Uprising Blog https://www.linuxuprising.com/2020/12/how-to-repeat-command-every-x-seconds.html
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Henry Crun@mike@rechtman.com to alt.os.linux.ubuntu on Thu Apr 8 15:47:19 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 08/04/2021 14:54, gamo wrote:
    El 7/4/21 a las 22:03, Anssi Saari escribió:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Well, if your script dies due to some error condition, then with option
    1 it stays dead until you reboot.

    On the other hand, if you run it with cron every minute then it runs for
    sure. And if there's an error then you get an email once a minute about
    it...


    Well in Ubuntu desktop you are not emailed in option 2, but anyway I
    would chose the option 1 maybe because it's more transparent and you
    could modify it, in example a 'sleep 60' is not exactlly once per minute because the task takes time and so on...


    my preference would be to combine the two approaches:
    write, compile and link in the language of your choice, using whatever "wait 60" or "sleep 60" or equvalent the language
    provides. This will save the program setup 60 times a hour
    In cron setup a script to run every 1 or 2 hours to check that your program is still executing, and restart it if
    neccesary; you could email on whatever event you choose

    (can you see I come from an OS where program initialization takes a toll...?)

    --
    Mike R.
    Home: http://alpha.mike-r.com/
    QOTD: http://alpha.mike-r.com/qotd.php
    No Micro$oft products were used in the URLs above, or in preparing this message.
    Recommended reading: http://www.catb.org/~esr/faqs/smart-questions.html#before
    and: http://alpha.mike-r.com/jargon/T/top-post.html
    Missile address: N31.7624/E34.9691
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Chris Elvidge@chris@mshome.net to alt.os.linux.ubuntu on Thu Apr 8 14:39:39 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 07/04/2021 02:27 pm, Michael F. Stemper wrote:
    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?


    There's another option : systemd-timers
    Article about it/them: https://opensource.com/article/20/7/systemd-timers

    --
    Chris Elvidge
    England
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Jonathan N. Little@lws4art@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 09:52:57 2021
    From Newsgroup: alt.os.linux.ubuntu

    gamo wrote:
    Well in Ubuntu desktop you are not emailed in option 2

    Only because the email is not defined for the crontab user by default
    adding line:

    MAILTO="your@email.address"

    to your crontab settings, and a local relay server like nullmailer to
    send messages to remote mailserver.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 13:06:50 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 07/04/2021 15.03, Anssi Saari wrote:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Well, if your script dies due to some error condition, then with option
    1 it stays dead until you reboot.

    On the other hand, if you run it with cron every minute then it runs for sure. And if there's an error then you get an email once a minute about
    it...

    Fortunately, my system doesn't know my email address.

    However, I started running option 2 yesterday and learned that although
    I had disabled cron logging to /var/log/syslog, somehow I missed
    keeping it from logging to /var/log/auth.log, which gives me two more
    messages per minute, making it (auth.log) pretty useless.


    --
    Michael F. Stemper
    Why doesn't anybody care about apathy?
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 13:08:21 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 08/04/2021 06.54, gamo wrote:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.


    Well in Ubuntu desktop you are not emailed in option 2, but anyway I
    would chose the option 1 maybe because it's more transparent and you
    could modify it, in example a 'sleep 60' is not exactlly once per minute because the task takes time and so on...

    Not a problem; as I said, I want to run it roughly once a minute. A
    slippage of a second or two per hour isn't a big deal.

    --
    Michael F. Stemper
    Why doesn't anybody care about apathy?
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 13:12:44 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 08/04/2021 07.47, Henry Crun wrote:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    my preference would be to combine the two approaches:
    write, compile and link in the language of your choice,

    It's a bash script, so no compilation or linking is required.

    using whatever
    "wait 60" or "sleep 60" or equvalent the language provides.

    "sleep 60"

    In cron setup a script to run every 1 or 2 hours to check that your
    program is still executing, and restart it if neccesary; you could email
    on whatever event you choose

    I don't think that would be an option, as I've never configured a mail
    server.

    --
    Michael F. Stemper
    Why doesn't anybody care about apathy?
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 13:15:50 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 08/04/2021 07.43, Andrei Z. wrote:
    Michael F. Stemper wrote:
    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?

    Repeat a command every x interval of time in terminal? - Ask Ubuntu https://askubuntu.com/questions/430382/repeat-a-command-every-x-interval-of-time-in-terminal

    I don't want it running in a terminal, I want it running in the
    background, as is done by cron.

    How To Repeat A Command Every X Seconds On Linux - Linux Uprising Blog https://www.linuxuprising.com/2020/12/how-to-repeat-command-every-x-seconds.html

    The "watch" option that page suggests isn't appropriate, because I want
    it running in the background.

    The "sleep" option it suggests is exactly what I gave as my first option
    in my original post.

    --
    Michael F. Stemper
    Psalm 94:3-6
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Thu Apr 8 13:23:37 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 08/04/2021 08.39, Chris Elvidge wrote:
    On 07/04/2021 02:27 pm, Michael F. Stemper wrote:
    I have a process that I'd like to run roughly once a minute. There
    are two options:

    1. Wrap it in a script with a while [ 1 ] and a sleep 60. Have the
    wrapper kicked off by an @reboot entry in my crontab.
    2. Have it directly executed every minute by a five-stars entry in
    my crontab.

    What are the pros and cons of each approach?


    There's another option : systemd-timers
    Article about it/them: https://opensource.com/article/20/7/systemd-timers

    Oh, that's interesting. I never even heard of those before. This
    will take some reading. Thanks.

    --
    Michael F. Stemper
    Psalm 94:3-6
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From gamo@gamo@telecable.es to alt.os.linux.ubuntu on Fri Apr 9 02:52:22 2021
    From Newsgroup: alt.os.linux.ubuntu

    El 8/4/21 a las 14:47, Henry Crun escribió:
    In cron setup a script to run every 1 or 2 hours to check that your
    program is still executing, and restart it if neccesary; you could email
    on whatever event you choose


    Fully agree!!!

    That's a compromise solution between launching a lot of times a 'stupid' program and that the program takes care of doing a rerun and report
    possible problems in the execution or input/output possible problems.

    (can you see I come from an OS where program initialization takes a toll...?)

    Yes. And you could have a long beard.

    Off topic: I download the hercules emulator but realized that
    configuration shows that's not-for-humans software, like
    trolling in the devices equivalents that 0009 is /
    By the way, I will be pleased if anyone pass a "normal"
    hercules.cnf archive and could run the z/Arch emulator
    mode.

    Cheers.

    --
    http://gamo.sdf-eu.org/
    perl -E 'say "Code could contain bugsh";'
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Anssi Saari@as@sci.fi to alt.os.linux.ubuntu on Fri Apr 9 09:35:47 2021
    From Newsgroup: alt.os.linux.ubuntu

    "Michael F. Stemper" <mstemper@gmail.com> writes:

    However, I started running option 2 yesterday and learned that although
    I had disabled cron logging to /var/log/syslog, somehow I missed
    keeping it from logging to /var/log/auth.log, which gives me two more messages per minute, making it (auth.log) pretty useless.

    I guess curious minds want to know, what is it that you want to run
    every minute?
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From gamo@gamo@telecable.es to alt.os.linux.ubuntu on Fri Apr 9 09:38:01 2021
    From Newsgroup: alt.os.linux.ubuntu

    El 9/4/21 a las 2:52, gamo escribió:
    I will be pleased if anyone pass a "normal"
    hercules.cnf archive

    No problem. I finally run it and realize that
    as an being an emulator, it's only designed to
    run mainframe software and it's not compatible
    with running local software, IMHO. It's a pitty
    yo can type POSIX and something friendly
    appairs :-)

    --
    http://gamo.sdf-eu.org/
    perl -E 'say "Code could contain bugsh";'
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Fri Apr 9 07:45:16 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 09/04/2021 01.35, Anssi Saari wrote:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    However, I started running option 2 yesterday and learned that although
    I had disabled cron logging to /var/log/syslog, somehow I missed
    keeping it from logging to /var/log/auth.log, which gives me two more
    messages per minute, making it (auth.log) pretty useless.

    I guess curious minds want to know, what is it that you want to run
    every minute?

    A script that writes CPU temperature to a file. Lines look like


    2021-04-09 07:42:51 59.0 3326
    2021-04-09 07:43:51 59.0 3332
    2021-04-09 07:44:51 59.0 3329


    --
    Michael F. Stemper
    Exodus 22:21
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Paul@nospam@needed.invalid to alt.os.linux.ubuntu on Fri Apr 9 14:12:30 2021
    From Newsgroup: alt.os.linux.ubuntu

    Michael F. Stemper wrote:
    On 09/04/2021 01.35, Anssi Saari wrote:
    "Michael F. Stemper" <mstemper@gmail.com> writes:

    However, I started running option 2 yesterday and learned that although
    I had disabled cron logging to /var/log/syslog, somehow I missed
    keeping it from logging to /var/log/auth.log, which gives me two more
    messages per minute, making it (auth.log) pretty useless.

    I guess curious minds want to know, what is it that you want to run
    every minute?

    A script that writes CPU temperature to a file. Lines look like


    2021-04-09 07:42:51 59.0 3326
    2021-04-09 07:43:51 59.0 3332
    2021-04-09 07:44:51 59.0 3329



    I suppose it would depend on what is still supported.

    https://askubuntu.com/questions/41794/how-to-monitor-log-server-hardware-temperatures-load

    Paul
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Michael F. Stemper@mstemper@gmail.com to alt.os.linux.ubuntu on Fri Apr 9 14:03:07 2021
    From Newsgroup: alt.os.linux.ubuntu

    On 09/04/2021 13.12, Paul wrote:
    Michael F. Stemper wrote:
    On 09/04/2021 01.35, Anssi Saari wrote:

    I guess curious minds want to know, what is it that you want to run
    every minute?

    A script that writes CPU temperature to a file. Lines look like


    2021-04-09 07:42:51 59.0 3326
    2021-04-09 07:43:51 59.0 3332
    2021-04-09 07:44:51 59.0 3329

    I suppose it would depend on what is still supported.

    https://askubuntu.com/questions/41794/how-to-monitor-log-server-hardware-temperatures-load

    My script is a wrapper around the sensors command which that
    page references.

    If there's some pseudo-file in /proc that has this information,
    I'd happily take it directly from there.

    --
    Michael F. Stemper
    Galatians 3:28
    --- Synchronet 3.18a-Linux NewsLink 1.113