Run script no more than twice daily WITHOUT cron

Can I run a script no more than twice a day without using cron?

Maybe create a file when script is first run and check its date?

Yes, you can do anything you want.

In these forums, we expect people to post their work (their code) and not just post abstract questions.

So, yes, it's possible of course. But please post your code what you have tried
when asking questions.

Search these forums as well, and look at the bottom left of this page under "More UNIX and Linux Forum Topics You Might Find Helpful"

Hello!

Per forum rules, and the benefit of all users, please search the forums before posting a question.

You can easily search the forums using our internal Google search engine or our advanced internal search engine. You can also search our huge UNIX and Linux database by user generated tags or search the database for unanswered questions and provide an answer.

Thank you.

The UNIX and Linux Forums

I posted no code because i dont know where to start. My ? Was not abstract.

My question clearly stated the problem.

I am no expert, but am always learning.

No answer to my pm to you?

------ Post updated at 10:53 AM ------

I did so before posting.

The place to ask questions in the forums about how to do something in the forums is here:

Never by PM.

Two clear answers to your clear questions:

  • Yes
  • One of several possibilities.

OK, joking apart - what keeps you from using the proven system component cron ?
Do you know about the at command to schedule events?
A (not optimal) approach would be to calculate the time difference from (now till schedule time) in seconds and sleep that long.

Did you?

You can do this, but be careful that you don't run into a race condition, if the script is started twice at nearly the same time. Also, if someone deletes or manipulates your "control file", this protection is lost.

Other possibilities are to use the

at

command, or use a master script, which starts your script exactly twice. Of course in this case you have to ensure that the master script itself is not run twice.