LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2017, 09:49 AM   #1
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Rep: Reputation: Disabled
crontab to run 59 minutes, 23rd hour, every single day?


59 23 * * * /home/scott/Desktop/mmm.sh


Will this run the script at 23:59 every single day?

I dont suppose you can have it run at seconds like
23:59:50 ?
so 10 seconds before midnight.
 
Old 07-09-2017, 09:50 AM   #2
jmgibson1981
Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 678

Rep: Reputation: Disabled
only minutes. yes that looks correct for 23:59
 
Old 07-09-2017, 09:54 AM   #3
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Thanks, I realized my script if set to run at @midnight would record the file names with the next day what was recorded the previous day, which would not make sense.
So if one minute of recording happens after 23:59, it will be shoved into the next day, but I can live with it.

This is my script line

mv /home/scott/testmotion/motion-files /home/scott/testmotion/motion-files--$(date +%a-%m-%d-%Y---%H:%M:%S)

Last edited by sdowney717; 07-09-2017 at 09:57 AM.
 
Old 07-09-2017, 12:23 PM   #4
af7567
Member
 
Registered: Nov 2012
Posts: 213

Rep: Reputation: 78
If you wanted it to run closer to midnight you could make it run at 23:59 and put a "sleep 50" at the start of your script to make it wait before doing anything.

edit: you might want to check that it does get run at exactly 23:59 by cron first though, if cron is a bit behind and you make your sleep too long then it could end up running after midnight.

Last edited by af7567; 07-09-2017 at 12:25 PM.
 
Old 07-09-2017, 06:53 PM   #5
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by af7567 View Post
If you wanted it to run closer to midnight you could make it run at 23:59 and put a "sleep 50" at the start of your script to make it wait before doing anything.

edit: you might want to check that it does get run at exactly 23:59 by cron first though, if cron is a bit behind and you make your sleep too long then it could end up running after midnight.
Thanks, good idea to sleep.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to: Script run every 1 hour between 18h and 7h every day heathcliffz Linux - General 5 12-08-2015 09:02 AM
Running a cron every 7 minutes but to cary over the 7 minute count to the next hour? ghurty Linux - Server 15 10-09-2013 06:45 PM
Raspberry Pi UTC time out by 1 hour and 27 minutes jimdaworm Linux - Software 4 09-13-2013 02:59 AM
Connection refused after 15 to 30 minutes, sometimes an hour lmu9@yahoo.com Linux - Networking 1 12-17-2009 10:13 AM
crontab 24-hour time cleopard Linux - General 2 05-09-2006 07:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration