Schedule a shell script without crontab every Wednesday at 10 AM

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

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...

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 ).

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

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

!/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)?

2 Likes

Just thought I'd add to what Don Cragun 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.