0

I need to schedule a cron job to run on the "last working day" of the month. Please can someone advise me on how to achieve that?

thanks Nick

5
  • any advice would be very much appreciated...
    – nick
    Sep 19, 2019 at 16:59
  • 3
    Month and day are well defined, but you do need to specify what you mean by "working day". Sep 19, 2019 at 18:46
  • Hi, by that I mean I need a process to run a process at end of the month as in the last weekday (exc Sat & Sun). So if the last day is 31st (Sun), 29th (Friday) would be the last working day.
    – nick
    Sep 20, 2019 at 9:18
  • I've created a below script and i dont know if this is the right approach. Please can you experts help me to get this to work if this is thre only best way to achieve what im after? #!/usr/bin/bash typeset -i x1_day_of_month=date +"%d"` typeset -i x1_month_of_year=date +"%b" typeset -i x1_year=date +"%Y" x1_datestring=$x1_day_of_month $x1_month_of_year $x1_year x1_listofdates=" 30Sep2019 if [ "$x1_D" = "$x1_$listofdates"] ; then echo "Run job" elseif [ $x1_FLAGRUN != 1 ] ; then echo "do not run fancyjob today" exit`
    – nick
    Sep 20, 2019 at 12:09
  • There is a more concise method that I have successfully tested: serverfault.com/questions/55481/…
    – VeRo
    Jan 31, 2023 at 12:21

2 Answers 2

2

It's not possible to do this with cron alone. You will have to run your application every day and have it decide if today is a the last working day of a month or not and take appropriate action.

2
  • please can you advise on how i should proceed. thanks.
    – nick
    Sep 20, 2019 at 14:46
  • 1
    My best advice is to use the on site search or your favourite search engine.,
    – user9517
    Sep 20, 2019 at 17:18
0

You can do this with the syntax below:

0 0 LW * ?.

1
  • This does not work, did you check it ? If so, where ? We should always strive to give accurate and useful answers.
    – VeRo
    Jan 31, 2023 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .