Sleep command wait till tomorrow

sleep command wait till tomorrow 7:00 am .

Below command not work for me

    endTime=$(date -d "Tomorrow 07:00AM" +%s)
    sleep $endTime

Open in new window

i know can add second for sleep command but how can i tell to sleep wait till Tomorrow 7:00 Am ?
Mehran GoudarziAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
I have virtually no knowledge on the topics of the thread, but never seen anyone asking process to sleep for that long.

Which is the operating system? Why not resort to Scheduled Task / Cron job, or similar.
Mehran GoudarziAuthor Commented:
    startTime=$(date +%s)
    endTime=$(date -d "tomorrow 07:30:00" +%s) 
    timeToWait=$(($endTime- $startTime))
    sleep $timeToWait

Open in new window

This helped me Thanks .

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
I would argue the correct way of doing this is with a CRON job.

There are many reasons why you should not rely on a sleep function to do this.

CRON jobs are precisely for this scenario - set them up to run when they need to and have your script do what needs to be done as quickly as possible.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

nociSoftware EngineerCommented:
If the process gets killed, (f.e. system reboot) then the sleep terminates and never will wake up.
cron or at  (atd task) will take care of that...
I concur with the other comments that you should not be letting a process sleep for this long. You are just begging for more problems later on. A scheduler like cron should be used here.
Bernard S.CTOCommented:
THe fact that the asker solution "did work" is fine. However, as spotted by other experts this is not the right way to do it.

As spotted by @noci the (only single) correct way to do this is with an atd/at job
Cron is better suited for repetitive job, which is not the case here
While it might not be the right way to do it, I wouldn't suggest objecting to the closure. If an OP wants to do something against the recommendations of several experts, then that might be the only way for him/her to learn (or there's a slight chance that the OP knows and has not shared contextual information that invalidates the expert recommendations). I'd recommend letting the question close if that's what the OP decides to do.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.