# Cron tab time generation script

**URL:** <https://community.unix.com/t/cron-tab-time-generation-script/334769>\
**Category:** Shell Programming and Scripting\
**Created:** [September 27, 2013, 4:54am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769 "2013-09-27T04:54:34Z")\
**Posts on this page:** 5\
**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:** [September 27, 2013, 4:54am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769/1 "2013-09-27T04:54:34Z")

</div>

Hi folks,

Everyone knows about crontab, what i am looking for a script where i will define hour,minute and day and it will generate crontab complete time entry, i have seen many website generating crontab entry and my question is that is there any shell script that can do same work.

```nohighlight

20 09 * * 5 command

```

---

<div class="post-metadata">

**Author:** ![inventsekar](https://community.unix.com/user_avatar/community.unix.com/inventsekar/32/8425_2.png) [@inventsekar](https://community.unix.com/u/inventsekar)\
**Post date:** [September 27, 2013, 5:44am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769/2 "2013-09-27T05:44:38Z")

</div>

Hello,  
assuming three command line parameters as:  
$cronscript.sh \<hr\> \<min\> \<day\>

the script would be:

```nohighlight
HR=$1
MIN=$2
DAY=$3

crontab -l > cron_now
#add new cron into cron file
echo "$MIN $HR * * $DAY script-which-needs-to-be-added-to-cron" >> cron_now
#install the new cron_now file
crontab cron_now
#remove the temp cron_now file
rm cron_now

```

---

<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:** [September 27, 2013, 5:50am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769/3 "2013-09-27T05:50:41Z")

</div>

Hi,

I am talking about this, do we have some shell script like that?

[http://www.thepcmanwebsite.com/crontab\_generator.shtml](http://www.thepcmanwebsite.com/crontab_generator.shtml)

---

<div class="post-metadata">

**Author:** ![inventsekar](https://community.unix.com/user_avatar/community.unix.com/inventsekar/32/8425_2.png) [@inventsekar](https://community.unix.com/u/inventsekar)\
**Post date:** [September 27, 2013, 5:54am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769/4 "2013-09-27T05:54:12Z")

</div>

Hi there,  
yes, my script does that exactly.  
ok, may i know exactly what you like to do. do you want to input the min, hr and day thru cmd line arg or thru reading from user? could you please provide more info..

---

<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:** [September 27, 2013, 6:04am UTC](https://community.unix.com/t/cron-tab-time-generation-script/334769/5 "2013-09-27T06:04:05Z")

</div>

> [@inventsekar](#):
>
> Hi there,  
> yes, my script does that exactly.  
> ok, may i know exactly what you like to do. do you want to input the min, hr and day thru cmd line arg or thru reading from user? could you please provide more info..

Thanks for your kind reply. Yes i want to input minute and hour and month, day of monday, day of week from command line, so it will show complete output.
