• last day of month in cron

    From tracedynamics@gmail.com@21:1/5 to Rodney Mach on Sat Jun 23 18:44:33 2018
    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling tool to serve your requirement.

    And one of such tool is autosys which is capable of scheduling, monitoring, and reporting.

    you can use autosys calendar functionality and set it up for every month last day.

    Naren
    https://www.tracedynamics.com/autosys/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tracedynamics@gmail.com@21:1/5 to Rodney Mach on Sat Jun 23 18:42:33 2018
    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling toll to server the same.

    one such tool is autosys which is capable of scheduling, monitoring, and reporting.

    So you use autosys calendar functionality and set it up for every month last day.

    Naren
    https://www.tracedynamics.com/autosys/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tracedynamics@gmail.com@21:1/5 to Rodney Mach on Sat Jun 23 18:46:10 2018
    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling tool to server your requirement.

    and one of such tool is autosys which is capable of scheduling, monitoring, and reporting.

    You use autosys calendar functionality and set it up for every month last day.

    Naren
    https://www.tracedynamics.com/autosys/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bit Twister@21:1/5 to tracedynamics@gmail.com on Sat Jun 23 21:56:27 2018
    On Sat, 23 Jun 2018 18:42:33 -0700 (PDT), tracedynamics@gmail.com wrote:
    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling toll to server the same.

    one such tool is autosys which is capable of scheduling, monitoring, and reporting.

    So you use autosys calendar functionality and set it up for every month last day.


    Besides posting the same response three times, you might consider
    using a real Usenet client instead of G2/1.0.

    I can recommend using slrn. Nice scoring rules, and there is a utility
    to clean out the score file of expired scores.

    For what it is worth, pretty sure Rodney Mach has given up an a
    response posted 20 years ago. Note the line
    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tom@21:1/5 to tracedynamics@gmail.com on Sat Jun 23 22:06:57 2018
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling tool to server your requirement.

    and one of such tool is autosys which is capable of scheduling,
    monitoring, and reporting.

    You use autosys calendar functionality and set it up for every month
    last day.

    Naren
    https://www.tracedynamics.com/autosys/

    Yeah but he asked how to do it in Cron. I am curious as well.

    --
    _______________________________________
    / The average individual's position in \
    | any hierarchy is a lot like pulling a |
    | dogsled -- there's no real change of |
    \ scenery except for the lead dog. /
    ---------------------------------------
    \
    \
    /\ /\
    //\\_//\\ ____
    \_ _/ / /
    / * * \ /^^^]
    \_\O/_/ [ ]
    / \_ [ /
    \ \_ / /
    [ [ / \/ _/
    _[ [ \ /_/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Aragorn@21:1/5 to All on Sun Jun 24 10:07:19 2018
    On Sunday 24 June 2018 07:06, tom conveyed the following to
    comp.unix.admin...

    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month? I am assuming cron has some symbol that
    says "last day of every month" since every month
    doesn't have the same number of days. I didn't
    see it in the man page.

    Thanks!

    -Rod
    You can post here or send a line to rmach at umich edu

    You can use any job scheduling tool to server your requirement.

    and one of such tool is autosys which is capable of scheduling,
    monitoring, and reporting.

    You use autosys calendar functionality and set it up for every month
    last day.

    Naren
    https://www.tracedynamics.com/autosys/

    Yeah but he asked how to do it in Cron. I am curious as well.

    Just for the record, the original post with the question is from 1998.
    The person who replied to it is obviously a Google Grouper, because I
    didn't see that post, and I filter out Google Groups.

    As for the answer to the question, when all else fails, consult the
    manual. :p

    $ man crontab

    --
    With respect,
    = Aragorn =

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bit Twister@21:1/5 to tom on Sun Jun 24 06:06:41 2018
    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of month.
    If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Bit Twister on Thu Jun 28 17:25:39 2018
    Bit Twister wrote:

    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of month.
    If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    Alternatively....
    #!/bin/bash
    # If tomorrow is the 1st of the month,
    # then today is the last day of the month
    [ $(date +%-d -d tomorrow) != 1 ] && exit 0
    # code for last day of the month goes here


    --
    Lew Pitcher
    "In Skills, We Trust"
    PGP public key available upon request

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bit Twister@21:1/5 to Lew Pitcher on Thu Jun 28 19:32:34 2018
    On Thu, 28 Jun 2018 17:25:39 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of month.
    If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    Alternatively....
    #!/bin/bash
    # If tomorrow is the 1st of the month,
    # then today is the last day of the month
    [ $(date +%-d -d tomorrow) != 1 ] && exit 0
    # code for last day of the month goes here

    Cute. I like it. I wish I could think like that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Bit Twister on Fri Jun 29 10:54:57 2018
    Bit Twister wrote:

    On Thu, 28 Jun 2018 17:25:39 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of month.
    If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    Alternatively....
    #!/bin/bash
    # If tomorrow is the 1st of the month,
    # then today is the last day of the month
    [ $(date +%-d -d tomorrow) != 1 ] && exit 0
    # code for last day of the month goes here

    Cute. I like it. I wish I could think like that.

    It may be possible (should be possible, but I've never tried it) to
    incorporate this test directly into the crontab entry, rather than requiring the crontab entry to run a shell script.

    Something like
    1 0 28-31 * * [ $(date +%-d -d tomorrow) = 1 ] && do_this

    where
    do_this
    is the path to the executable to be executed on the last day of the month.


    --
    Lew Pitcher
    "In Skills, We Trust"
    PGP public key available upon request

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bit Twister@21:1/5 to Lew Pitcher on Fri Jun 29 10:19:51 2018
    On Fri, 29 Jun 2018 10:54:57 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Thu, 28 Jun 2018 17:25:39 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote:
    What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of month. >>>> If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    Alternatively....
    #!/bin/bash
    # If tomorrow is the 1st of the month,
    # then today is the last day of the month
    [ $(date +%-d -d tomorrow) != 1 ] && exit 0
    # code for last day of the month goes here

    Cute. I like it. I wish I could think like that.

    It may be possible (should be possible, but I've never tried it) to incorporate this test directly into the crontab entry, rather than requiring the crontab entry to run a shell script.

    Something like
    1 0 28-31 * * [ $(date +%-d -d tomorrow) = 1 ] && do_this

    where
    do_this
    is the path to the executable to be executed on the last day of the month.

    Personally, I do not want to mess with crontab. I do clean installs on
    each new release of my Linux install, so that is one less file to
    change. I'll let the scripts decide if it is the date to do something.

    To reduce my admin work, I have set users users to have their own cron subsystem and my system /local/,cron setup. That way all anyone has to
    do is drop a script into the desired queue.


    $ ls -Al /etc/cron* | grep local_cron_job
    lrwxrwxrwx 1 root root 25 Jun 14 12:33 _daily -> /local/bin/local_cron_job lrwxrwxrwx 1 root root 25 Jun 14 12:33 _hourly -> /local/bin/local_cron_job lrwxrwxrwx 1 root root 25 Jun 14 12:33 _monthly -> /local/bin/local_cron_job lrwxrwxrwx 1 root root 25 Jun 14 12:33 _weekly -> /local/bin/local_cron_job


    ]$ cat /local/bin/local_cron_job
    #!/bin/bash #************************************************************************
    #*
    #* local_cron_job - cron job to run /local/cron/(hourly|daily...) jobs
    #*
    #*
    #* Usually called from /etc/cron.hourly, daily, monthly,.....
    #*
    #* Usage: link _name to /local/bin/local_cron_job
    #*
    #* Example: cd /etc/cron.hourly
    #* ln -s /local/bin/local_cron_job _hourly
    #* Leading underscore on _name is important
    #* because it is removed to get directory name in /local/cron and
    #* causes it to be executed before any other jobs in the directory.
    #*
    #***********************************************************************

    /local/bin/cronlock check
    if [ $? -eq 0 ] ; then
    exit 0
    fi

    _exe=${0##*/}

    _job=${_exe:1}

    if [ ! -d /local/cron/$_job ] ; then
    echo "$_exe FATAL error:"
    echo "$0 link is incorrect"
    echo "or /local/cron/$_job does not exist"
    /bin/false
    else
    nice -n 19 run-parts --report /local/cron/$_job
    /bin/true
    fi

    #*********************** end local_cron_job *******************************



    User cron jobs are setup the same way. For example:

    # cat /var/spool/cron/bittwister
    #*************** start of $HOME/.cron/cron.job ***************************
    #
    ####################################################################
    # syntax example #
    #minute (0-59), #
    #| hour (0-23), #
    #| | day of the month (1-31), #
    #| | | month of the year (1-12), #
    #| | | | day of the week (0-6 with 0=Sunday)#
    #| | | | | commands #
    #30 01 * * * /home/jim/bin/cleartmp # #################################################################### SHELL=/bin/bash
    MAILTO=bittwister
    HOME=/home/bittwister
    _cron_loc=/home/bittwister
    PATH=/usr/local/sbin:/usr/sbin\
    :/usr/local/bin:/usr/bin:/local/bin:/usr/games\
    :/home/bittwister/local/bin
    #
    31 0-23 * * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/hourly
    25 5 * * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/daily
    30 5 * * 0 /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/weekly
    40 5 1 * * /bin/nice -n 19 /usr/bin/run-parts $_cron_loc/.cron/monthly
    52 5 * * * /bin/nice -n 19 /local/bin/ck_mail_msg
    #*
    #* Install: click up a terminal,
    #* su - root
    #* cp ~bittwister/.cron/cron.job /var/spool/cron/bittwister
    #* chown bittwister:bittwsiter /var/spool/cron/bittwister
    #* chmod 600 /var/spool/cron/bittwister
    #* exit
    #* exit
    #*
    #************* end ~bittwister/.cron/cron.job *************************

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Bit Twister on Fri Jun 29 11:42:41 2018
    Bit Twister wrote:

    On Fri, 29 Jun 2018 10:54:57 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Thu, 28 Jun 2018 17:25:39 -0400, Lew Pitcher wrote:
    Bit Twister wrote:

    On Sat, 23 Jun 2018 22:06:57 -0700, tom wrote:
    On Sat, 23 Jun 2018 18:46:10 -0700 (PDT)
    tracedynamics@gmail.com wrote:

    On Tuesday, June 23, 1998 at 3:00:00 AM UTC-4, Rodney Mach wrote: >>>>>>> > What is the best way to run a job on the last day of
    every month?

    <snip>

    Yeah but he asked how to do it in Cron. I am curious as well.


    Sounds easy to me. Put a script in cron daily and use the calendar
    program to get last day of month and compare with current day of
    month. If current day is not last day exit. Suggested reading:
    man date
    man cal
    man test

    For example:

    #!/bin/bash
    Current_Day_of_Month=$(date '+%_d')
    Last_Day_of_Month=$(set $(cal);shift $(( $# - 1));echo $1)

    if [ $Current_Day_of_Month -ne $Last_Day_of_Month ] ; then
    exit 0
    fi

    code for last day of month goes here

    Alternatively....
    #!/bin/bash
    # If tomorrow is the 1st of the month,
    # then today is the last day of the month
    [ $(date +%-d -d tomorrow) != 1 ] && exit 0
    # code for last day of the month goes here

    Cute. I like it. I wish I could think like that.

    It may be possible (should be possible, but I've never tried it) to
    incorporate this test directly into the crontab entry, rather than
    requiring the crontab entry to run a shell script.

    Something like
    1 0 28-31 * * [ $(date +%-d -d tomorrow) = 1 ] && do_this

    where
    do_this
    is the path to the executable to be executed on the last day of the
    month.

    Personally, I do not want to mess with crontab.

    Personally, I'm comfortable managing crontab. Not that I have to do it very often, but I don't fear it.

    If you find your way easier and/or more comfortable, then who am I to argue? :-)

    As for run-parts and the cron.* directories, I also have my own way of
    managing the scripts within. The Slackware (my distro of choice) version of run-parts single-threads the scripts it executes, and only reports
    completion when /all/ scripts are done. That's not to my liking; I wanted
    each script to run in parallel (with some synchronization where necessary),
    so I came up with my own add-on. The original scripts in /etc/cron.daily
    (for instance) run undisturbed, one after another, while those scripts I
    want run in parallel run in parallel. If you are interested, you can read my notes (and get the source) here -> http://justlinux.ca/software/Rmonitor

    [snip]

    Luck be with you
    --
    Lew Pitcher
    "In Skills, We Trust"
    PGP public key available upon request

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)