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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-07-2023, 12:28 PM
|
#1
|
Member
Registered: Apr 2017
Distribution: Artix
Posts: 345
Rep:
|
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
|
|
|
05-07-2023, 01:25 PM
|
#2
|
Senior Member
Registered: Dec 2011
Location: Simplicity
Posts: 2,918
|
Code:
#!/bin/bash
hour=$( date "+%_H" )
if (( $hour >= 6 && $hour < 9 ))
then
echo "run"
fi
|
|
1 members found this post helpful.
|
05-07-2023, 01:27 PM
|
#3
|
LQ Guru
Registered: Oct 2004
Distribution: Arch
Posts: 5,219
|
|
|
|
05-07-2023, 04:27 PM
|
#4
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,146
|
Quote:
Originally Posted by BudiKusasi
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".
|
|
|
05-07-2023, 05:12 PM
|
#5
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,323
|
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.
|
05-07-2023, 05:40 PM
|
#6
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,146
|
Quote:
Originally Posted by dugan
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".
|
|
|
05-08-2023, 12:19 AM
|
#7
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,295
|
@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.
|
05-08-2023, 06:19 AM
|
#8
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,323
|
Quote:
Originally Posted by TB0ne
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.
|
All times are GMT -5. The time now is 09:48 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|