LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2023, 12:28 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
Bash codes with some time-conditions


How is Bash code to run a binary or command else with some time-conditions eg. pseudocode

if time is between 6:00 - 9:00 run foo.sh

else if time is between 9:00 - 12:00 run bar.sh

else run foobar.sh


Please help out
 
Old 05-07-2023, 01:25 PM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199
Code:
#!/bin/bash
hour=$( date "+%_H" )
if (( $hour >= 6 && $hour < 9 ))
then
  echo "run"
fi
 
1 members found this post helpful.
Old 05-07-2023, 01:27 PM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Look at rtcwake and at and cron

https://www.man7.org/linux/man-pages...rtcwake.8.html
https://man7.org/linux/man-pages/man1/at.1p.html
https://man7.org/linux/man-pages/man8/cron.8.html
 
Old 05-07-2023, 04:27 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by BudiKusasi View Post
How is Bash code to run a binary or command else with some time-conditions eg. pseudocode
Code:
if time is between 6:00 - 9:00 run foo.sh   
  else if time is between 9:00 - 12:00 run bar.sh    
  else run foobar.sh
Please help out
Can you show us what you've done/tried to accomplish your goals?? And have you actually thought about what you're asking, and about the MANY ways to accomplish it?? Why can't you write ONE SCRIPT (since they're both shell scripts) that checks the time and acts accordingly?? Or writing one script that checks the time then calls either of the other two scripts, and just put that in cron?

You also don't say how often this script is going to run, but there are literally HUNDREDS of posts on this forum that have many examples on how to use cron in a very granular way...have you done any research of your own? Seems to be a pattern with your posts, where you just say "please help out", but don't show us what you've done first. Read the LQ Rules and the "Question Guidelines".
 
Old 05-07-2023, 05:12 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Like I said before, I'm pretty sure Budikusasi is a computer program that generates nonsense threads.

Notice how it literally never follows up on any of its threads.
 
2 members found this post helpful.
Old 05-07-2023, 05:40 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by dugan View Post
Like I said before, I'm pretty sure Budikusasi is a computer program that generates nonsense threads. Notice how it literally never follows up on any of its threads.
Don't think they're a bot, but just someone who can't do their own work. The sad part is, others do it for them, so they have no incentive to NOT come back over and over asking for handouts.

If they actually posted something that showed effort/errors/details, that'd be one thing. But it's always "I have to do XXX, please help out".
 
Old 05-08-2023, 12:19 AM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
@BudiKusasi

Please review the Site FAQ for guidance in asking well formed questions. Especially visit the link from that page, How to Ask Questions the Smart Way for discussion of things to consider when asking others for help.

It is apparent that your behavior here is a concern for other members. Your posting history indeed shows that you almost always ask for a complete solution without showing any effort of your own, and you very rarely respond to those offering help either to interact in producing a solution or even to show the courtesy of saying Thank you.

The LQ Programming forum is a place for sharing knowledge and enthusiasm for computing, learning, teaching and for giving and receiving help with specific problems. But it is not an on demand help desk or a place to have others complete your tasks for you.

Please make effort to be a participant in that process. If you cannot do so you may be asked to find help elsewhere.
 
1 members found this post helpful.
Old 05-08-2023, 06:19 AM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by TB0ne View Post
Don't think they're a bot
This is one of the very few posts it made within the past year that wasn't the start of a new thread.

https://www.linuxquestions.org/quest...8/#post6381670

The question:

"Chess - What's the strongest GUI chess game for Linux ?"

The bot googles the keywords, including "GUI", scrapes the results page, and posts a link.

The link (emphasis in original):

"Stockfish does not include a graphical user interface (GUI)"

I'd say the mask has slipped.

Now, I was on a previous forum where a person was acting like this, to a lesser extreme. One of the comments on that person's behavior was "[username] just likes starting threads (or was it 'just likes asking questions'). Answers are irrelevant." Sure, it could be another one of those types of people, but BudiKusasi reminds me more of bots like these than it does that user:

https://twitter.com/MagicRealismBot

https://twitter.com/litpatches_txt

Last edited by dugan; 05-08-2023 at 07:12 AM.
 
2 members found this post helpful.
  


Reply



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
bash script: ftp then check some conditions before copy files MsComX Linux - Newbie 4 05-10-2022 02:34 PM
ns2 codes for OLSR codes sukrutha Linux - Newbie 3 01-25-2012 11:42 PM
[SOLVED] How to compile .jar Java byte-codes into native machine codes? ilgaar Linux - Software 1 08-30-2010 12:52 AM
How to compile .jar Java byte-codes into native machine codes? ilgaar Linux - Software 6 08-28-2010 11:20 PM
Are the hex codes for colors in a jpg the same codes as used in html? abefroman Linux - Security 3 07-31-2005 03:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:12 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