Register
It is currently Fri Oct 24, 2014 2:27 am

need help figuring out what a snip of code does


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat Jul 12, 2014 12:59 am   

Joined: Mon Jul 01, 2013 7:24 pm
Posts: 19
Pretty n00ber question I am sure, but I can't seem to figure out exactly what this snip of code does, if someone doesn't mind breaking it down for me:
Quote:
sleep $(( $(date --date="$at" +%s) - $(date +%s) ));

In very general terms the script `sleeps` for the duration in minutes, $at, the user sets before an alarm sounds. I ripped it from another script some time ago that I am now using with great success in an alarm script I hacked together.

The script is quite useful for my purposes and I use it many times a day. But my problem is that whenever I set an alarm that will extend into the next day (past midnight) the alarm simply goes off immediately, and I think it has to be this snip I need to understand better to modify so it allows alarms to extend past midnight.

If it would help to see it in context I could paste the rest of my alarm script.

cheers


Top
 Profile  
 PostPosted: Sat Jul 12, 2014 3:33 am   

Joined: Mon Jul 01, 2013 7:24 pm
Posts: 19
Found what I was looking for. I simply need to prepend the word "tomorrow" to the time assigned to var $at. Modified script and alarm does not sound off but is still sleeping, or is still a process at least, so I will assume it is going to work as I need.

But I am still quite hazy about what the snip does exactly or rather how it does what it does. If anyone would like to break it down so it makes more sense I would still appreciate the learning opportunity.


Top
 Profile  
 PostPosted: Mon Jul 14, 2014 8:56 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Perhaps if you could share your alarm script in it's entirety it would be helpful.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP