# Schedule a shell script without crontab every Wednesday at 10 AM

**URL:** <https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654>\
**Category:** Shell Programming and Scripting\
**Created:** [September 9, 2018, 1:18pm UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654 "2018-09-09T13:18:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kshitij](https://community.unix.com/letter_avatar/kshitij/32/6_449c533f586939b6e5f246632a46421f.png) [@kshitij](https://community.unix.com/u/kshitij)\
**Post date:** [September 9, 2018, 1:18pm UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/1 "2018-09-09T13:18:36Z")

</div>

HI Guys

I need one shell script to be scheduled to run one shell script to be executed automatically every Wednesday at 10 AM Without crontab and "at" command..

Could you provide your suggestions ?

Thanks and Regards  
kshitij Kulshreshtha

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [September 9, 2018, 3:48pm UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/2 "2018-09-09T15:48:42Z")

</div>

Q :  
How do you think possible to execute anything at a given time/day/date without a scheduling utility?

cron or at are the only ones you will find on all systems, after you have solutions ($$$) provided by vendors...

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [September 9, 2018, 7:26pm UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/3 "2018-09-09T19:26:03Z")

</div>

In addition to what vibe has already said, please also explain why you do not want to use the two utilities that are explicitly designed to do exactly what you want (i.e., `at` and `cron` ).

---

<div class="post-metadata">

**Author:** ![Neo](https://community.unix.com/user_avatar/community.unix.com/neo/32/22838_2.png) [@Neo](https://community.unix.com/u/Neo)\
**Post date:** [September 9, 2018, 9:12pm UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/4 "2018-09-09T21:12:33Z")

</div>

Normally these kinds of question indicate homework because these are the typical impractical questions you see in school.

---

<div class="post-metadata">

**Author:** ![kshitij](https://community.unix.com/letter_avatar/kshitij/32/6_449c533f586939b6e5f246632a46421f.png) [@kshitij](https://community.unix.com/u/kshitij)\
**Post date:** [September 10, 2018, 3:22am UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/6 "2018-09-10T03:22:27Z")

</div>

Well I have written this script , Not sure if it can be improved  
I dont have root access

```nohighlight
!/bin/csh

setenv next_week_w_old_time `date --d="next wed" +"%s"`
setenv curr_week_w_old_time `date +"%s"`

#setenv difference $(($next_week_w_old_time - $curr_week_w_old_time))
@ difference = $next_week_w_old_time - $curr_week_w_old_time
#echo $difference
sleep $difference
source shell_script

```

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [September 10, 2018, 6:47am UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/8 "2018-09-10T06:47:43Z")

</div>

> [@kshitij](#):
>
> Well I have written this script , Not sure if it can be improved  
> I dont have root access
> 
> ```plaintext
> !/bin/csh
> 
> setenv next_week_w_old_time `date --d="next wed" +"%s"`
> setenv curr_week_w_old_time `date +"%s"`
> 
> #setenv difference $(($next_week_w_old_time - $curr_week_w_old_time))
> @ difference = $next_week_w_old_time - $curr_week_w_old_time
> #echo $difference
> sleep $difference
> source shell_script
> 
> ```

What operating system are you using?

Is this script working the way you want it to work? I'm not aware of any system where the `date` utility has a `--d` option. Many systems have a `date` utility that doesn't even have a `-d` option. Does this script produce any diagnostic messages?

I don't see anything that is attempting to sleep until 10AM on Wednesday. And, if you start it before 10AM on a Wednesday, it would seem that your code might be trying to skip running on that day and instead try to wait for a week before running `shell_script` .

If the system is rebooted while your script is running, I don't see anything here that would attempt to restart it when the system comes back up to multi-user mode.

The `cron` , `crontab` , and `at` utilities are all designed to handle all of these issues. I repeat: Why do you want to reinvent the wheel when `crontab` and `at` are designed to handle all of the issues your current script seems to be lacking? Has your system's sys-admin decided that you should not be allowed to schedule jobs to run in the future by including your login name in the `cron.deny` file (if it is present) or by not including your login name in the `cron.allow` file (if it is present)?

---

<div class="post-metadata">

**Author:** ![Azrael](https://community.unix.com/user_avatar/community.unix.com/azrael/32/2411_2.png) [@Azrael](https://community.unix.com/u/Azrael)\
**Post date:** [September 10, 2018, 8:25am UTC](https://community.unix.com/t/schedule-a-shell-script-without-crontab-every-wednesday-at-10-am/373654/9 "2018-09-10T08:25:48Z")

</div>

Just thought I'd add to what [Don Cragun](https://www.unix.com/members/302122727.html) said. Your OS version may be deeply tied to script you are attempting to run. A few \*nix version have csh as a default shell. Most these days will not even have csh installed by default. Or it may be installed somewhere other than /bin/csh, like /usr/bin/csh. You might want to run a `which csh` to ensure its installed and the correct path is being used.
