# Expiry date of shell script

**URL:** <https://community.unix.com/t/expiry-date-of-shell-script/253441>\
**Category:** Shell Programming and Scripting\
**Created:** [November 11, 2009, 4:13pm UTC](https://community.unix.com/t/expiry-date-of-shell-script/253441 "2009-11-11T16:13:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![learnbash](https://community.unix.com/letter_avatar/learnbash/32/5_5575768a8748004e209b776fc1b2916d.png) [@learnbash](https://community.unix.com/u/learnbash)\
**Post date:** [November 11, 2009, 4:13pm UTC](https://community.unix.com/t/expiry-date-of-shell-script/253441/1 "2009-11-11T16:13:34Z")

</div>

Hello folks,

I have question about my expiry of shell script, today date is 2009-11-11, i will have to deploy a script today, how i should setup that my script will not work after 2010-05-11, Between if someone will change the date of server then script will again not work, please give suggestions and recommendation. I need to add this expiry part in shell script.

---

<div class="post-metadata">

**Author:** ![rdcwayx](https://community.unix.com/letter_avatar/rdcwayx/32/5_5575768a8748004e209b776fc1b2916d.png) [@rdcwayx](https://community.unix.com/u/rdcwayx)\
**Post date:** [November 11, 2009, 8:24pm UTC](https://community.unix.com/t/expiry-date-of-shell-script/253441/2 "2009-11-11T20:24:10Z")

</div>

timestamp will help you. If you have gnu date or your date command support %s , can use below code:

```nohighlight
date -d "2010-05-11" +%s
1273500000

```

After you get the timestamp, write a if-then-fi to compare the script running date with it.

---

<div class="post-metadata">

**Author:** ![learnbash](https://community.unix.com/letter_avatar/learnbash/32/5_5575768a8748004e209b776fc1b2916d.png) [@learnbash](https://community.unix.com/u/learnbash)\
**Post date:** [November 12, 2009, 8:14am UTC](https://community.unix.com/t/expiry-date-of-shell-script/253441/3 "2009-11-12T08:14:01Z")

</div>

> [@rdcwayx](#):
>
> timestamp will help you. If you have gnu date or your date command support %s , can use below code:
> 
> ```plaintext
> date -d "2010-05-11" +%s
> 1273500000
> 
> ```
> 
> After you get the timestamp, write a if-then-fi to compare the script running date with it.

Thanks for your kind reply, i have done it.

---

<div class="post-metadata">

**Author:** ![jgt](https://community.unix.com/user_avatar/community.unix.com/jgt/32/10703_2.png) [@jgt](https://community.unix.com/u/jgt)\
**Post date:** [November 12, 2009, 8:31am UTC](https://community.unix.com/t/expiry-date-of-shell-script/253441/4 "2009-11-12T08:31:28Z")

</div>

This does not prevent the script from being run by back dating the system date. You will also need to add a data file that keeps track of the current date and sets a flag when 2010-05-11 occurs so that the script will never run again no matter what the date, or get the current date from a place other than the system that you are running the script on.
