Cronjob cron.schedule payload issue - cron

How to write cronjob cron.schedule() when I am accepting values from mysql database in form of variables?
For example:
user will select a particular time when he wants to get reminded.
that time will go to database.
Then how do I write cron job cron.schedule at that particular time which is stored in my database?
Should I use dollar sign and use those variables containing those time values inside that variable like this?
Ex:- 11:30 pm
Code:-
cron.schedule(* $(minutes) $(hours)* * *) etc...

Related

Discord.py send dynamic time string

I'm currently working on a Bot where users can ask to play a game and set when to play it:
.play Valorant #30 -> "#anyone_who_is_playing_valorant, up for a round in 30 minutes?"
Currently, I'm editing the message every minute to display the correct time left, which unfortunately makes implementing other commands and functions way more difficult as it should be (while loop etc).
My only solution would be to display the time at which 30 minutes would be passed:
Message written at 17:00 -> "#anyone_who_is_playing_valorant, up for a round at 17:30?"
but due to timezones the displayed timestring has to be different for each user.
Actually, Discord supports such a function for embeds, but I haven't found a standart support for sending dynamic timestrings. I would imagine it to be like Pings, where there is no function but a syntax for it: <#!authorid>
Is there a way to send dynamic timestrings?
There is no dynamic time syntax in Discord messaging, the only such functionality is the timestamp in embeds as you mentioned.
Actually there is a way to have a dynamic string in your message but it does not work for the footer in the embed.
You only need to make a unix code,
from datetime import datetime
import calendar
date = datetime.utcnow()
utc_time = calendar.timegm(date.utctimetuple())
print(utc_time)
your output looks something like this: 1657723929
You format the code to this: <t:unixcode:R>
and it gives you
7 minutes ago
You can also make a timestamp which leads to the future with just adding the secconds to the unix code you just made e.g.:
this code <t:2665824929:R> represents
in 32 years
depends on when you see this because its dynamic

How can I to restrict the execution of an imacros script between some hours?

I have an imaros script that runs each 4 minutes (using auto clicker)... but I need to it doesn't run between 23:30 to 00:30... so I need to do something like:
If (date is <23:30 and date is > 00:30) then run!!
Is this possible?
many thanks!
This is possible with JavaScript. You can create current time in JS and compare it with time between the two times you named. It's a little complicated to make. Msg me on private messages and we can work things out.

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel

I have a requirement such that whenever i run my Kettle job, the database connection parameters must be taken dynamically from an excel source on each run.
Say i have an excel with column names : HostName, Username, Database, Password.
i want to pass these connection parameters to my table input step dynamically whenever the job runs.
This is what i was trying to do.
You can achieve this by
reading the DB connection parameters from a source (e.g. Excel or in my example a CSV file)
storing the parameters in variables
using the variables in your connection setting.
Proceed as follows
Create another transformation for setting the variables (you cannot do this in the same transformation that uses it):
In the Set Variables element configure the variables:
In the element reading/writing your data create a new connection and set the connection parameters using ${variable_name}. Note that you have to blindly write ${password} into the appropriate field. Also note that this may be a security issue because the value may show up as plain text in log files!
In your job call the variable transformation first and then the functional part:
All you need is the XLS input and the Set Variables step. Define your variables as being valid in the Root job and you can use them in subsequent jobs, as long as they're called by the same root job, when defining the connection.
The "Copy rows to result" and "Get rows from result" are used to send information (rows of data) from one transformation to the next transformation or job in the same parent job. They're not used to send data between steps, that's what the hops are for.

Cron Jobs Linux row deletion

I'm running this script;
$query = "SELECT * FROM XXX WHERE email='$Email'";
if($count==1) // fails
if($count==0) // succeeds
If successful
mysql_query ("INSERT INTO XXX (email) values ('$Email'");
Then proceeds onto the next script.
So, it checks to see if you have already ran this script in the past on that account, if you have your email is stored then you can't run this script ever again on that same email.
However, after this script has been processed I want it to delete the row created for the email after 6 hours.
So that after 6 hours they may run the script again.. I've been enlightened that I need to use Cron jobs for this, But I'm not sure how.. Any help is highly appreciated!
Many regards, and thanks in advance.
0 0,6,12,18 * * * /path/to/mycommand
This means starting from hour 0, 6, 12, and 18 the cron job would run. That would be the cron needed to do what you want.
Depending on which linux version you are running you will need to see how to actually create the cron job.
I would think at now +6 hours is a better choice here.

cron job for running a script based on db value

I had a sctipt runthisapp.sh and I am having some dates in my db table holiday . My problem is every day it should check the db ,if the date is present in holiday table runthisapp.sh should run at 10'o clock
Else
It should run at 8'o clock.
I had tried but can't find the solution .Can you.help me.on this please
You can have two crontab entries, one at 8am, one at 10am, passing different options to your script, e.g. the former takes --holiday=0, and the latter --holiday=1, and your script should just return doing nothing if in the wrong "holidayness".

Resources