# Script execution

**URL:** <https://community.unix.com/t/script-execution/349031>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [December 19, 2014, 2:40pm UTC](https://community.unix.com/t/script-execution/349031 "2014-12-19T14:40:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bala1985](https://community.unix.com/letter_avatar/bala1985/32/6_449c533f586939b6e5f246632a46421f.png) [@bala1985](https://community.unix.com/u/bala1985)\
**Post date:** [December 19, 2014, 2:40pm UTC](https://community.unix.com/t/script-execution/349031/1 "2014-12-19T14:40:34Z")

</div>

I need to call a script if the month end falls on Saturday or Sunday

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [December 19, 2014, 3:12pm UTC](https://community.unix.com/t/script-execution/349031/2 "2014-12-19T15:12:47Z")

</div>

Ok.

What code have you tried? Are you running the script in crontab?

---

<div class="post-metadata">

**Author:** ![bala1985](https://community.unix.com/letter_avatar/bala1985/32/6_449c533f586939b6e5f246632a46421f.png) [@bala1985](https://community.unix.com/u/bala1985)\
**Post date:** [December 19, 2014, 4:40pm UTC](https://community.unix.com/t/script-execution/349031/3 "2014-12-19T16:40:01Z")

</div>

No. i am not running the script in cron tab. Just if the month end falls on sat or sunday i need to run a script automatically. this should be done in shell scripting. i will create a autosys job for this and schedule it accordingly.

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [December 19, 2014, 5:32pm UTC](https://community.unix.com/t/script-execution/349031/4 "2014-12-19T17:32:36Z")

</div>

What is your system?

You need to check for two things, "month end" and "saturday or sunday". "Month end" is actually pretty difficult, since that's not predictable... Do you have GNU date? Or cal?

---

<div class="post-metadata">

**Author:** ![gowron](https://community.unix.com/letter_avatar/gowron/32/6_449c533f586939b6e5f246632a46421f.png) [@gowron](https://community.unix.com/u/gowron)\
**Post date:** [January 15, 2015, 8:27am UTC](https://community.unix.com/t/script-execution/349031/5 "2015-01-15T08:27:48Z")

</div>

You could try a different approach, write a script that runs daily at a time that you manual execution is finished. If your execution can be marked somehow (by touching a file or something) then the script would be able to understand if it is a normal or off work day and act accordingly (it would work for holidays too...)

---

<div class="post-metadata">

**Author:** ![rbatte1](https://community.unix.com/letter_avatar/rbatte1/32/6_449c533f586939b6e5f246632a46421f.png) [@rbatte1](https://community.unix.com/u/rbatte1)\
**Post date:** [January 15, 2015, 9:33am UTC](https://community.unix.com/t/script-execution/349031/6 "2015-01-15T09:33:15Z")

</div>

So, you say that you want to run it automatically. When would you want it running? Friday, the day that is the last day of the month, Monday following, or some other variation? How do you run it when the last day of the month is a Monday-Friday?

You could run the script each Friday (if that is what suits) and look forward to see if Sunday is the next month (i.e. Saturday is last-day-of-month), then check if Monday is next month (i.e. Sunday is last-day-of-month)

You can try to manipulate the TZ variable on some systems (AIX and others) to get differences to the actual clock so you can get forward or backward values to do your testing, perhaps use cal and read the current month calendar somehow or other ways.

BUT you haven't really nailed down the logic in what you want to do or how you plan to automate it.

Other questions that pop up are if the Friday is a National/Public/Bank Holiday. What would you want to do there?

Can you be more precise in your definition? We can look to options for helping you then.

Regards,  
Robin
