I created a web services using cakephp that store on mysql some data including date and time provided by an android app.
now I want send data to another device on that precise date and time (kind of cron job ) but I didn't find how to do that !
any ideas how to solve that?!
Yes, that's possible using a cronjob per minute
Command for the cronjob
* * * * * wget -q --spider http://example.com/controller/function
In the controller function check that precise date and time against the current date time, and they match, perform your action
$current_time = date("Y-m-d H:i:s");
$precise_time = "2017-05-12 9:52:00"; // for example
if($current_time == $precise_time){
// Send data to another device
}
Related
My configured email report is named "Raw player games" with crontab */20 * * * * (At every 20th minute I will expect a report in my email box). Look in the screenshot raw player games.
Another crontab is configured in main superset config - superset_config.py
# superset_config.py
CELERYBEAT_SCHEDULE = {
'email_reports.schedule_hourly': {
'task': 'email_reports.schedule_hourly',
'schedule': crontab(minute=1, hour='*'), # At minute 1, every hour
},
}
I receive emails, but only one per hour. I don't see any errors in logs, all jobs in celery flower are in success state.
apache-superset==0.37.2
celery==4.4.7
Why?
Why superset send me reports only once in a hour? How to reconfigure superset to correctly handle my crontabs, what I missed?
Note that your beat schedule is configured to run hourly. So on every minute one of each hour, beat is going to enqueue a new job that will verify if it's time to send a new report. It will not matter to have a thinner resolution configured on superset itself.
Yet by default email reports functionality has an hourly resolution:
https://github.com/apache/incubator-superset/blob/master/superset/tasks/schedules.py#L823
This default can be changed by configuring:
EMAIL_REPORTS_CRON_RESOLUTION
I have to run a stored procedure from azure webjob in continous mode.
I have written the code in c# and deployed the same in my development environment.
After monitoring for 3 or 4 days i found, the webjobs aborts if stored procedure runs for long time. My procedure takes approx 50 seconds to return output. While the job aborts by then.
It works fine if stores procedure returns data quickly. Where as if data is more and procedure takes time , i get aborted. But in my case i am looking to keep the job tunning till procedure returns data.
I am not able to figure it out.
I have tried below options
Turning always on ON
stopping_wait_time : 300
Is there any suggestion.?
You can use below code to set the timeout period to solve your problem. For more details, you can see this post about asynchronously wait for Task to complete with timeout. You also can choose other code to implement.
int timeout = 1000;
var task = SomeOperationAsync();
if (await Task.WhenAny(task, Task.Delay(timeout)) == task) {
// task completed within timeout
} else {
// timeout logic
}
Due to your azure webjob in continous mode, you can't use WEBJOBS_IDLE_TIMEOUT setting. But your webjobs will always on, you also can set WEBJOBS_RESTART_TIME to re-launch.
I have set up a flask application that records voice using python(sounddevice and pydub) libraries and converts it into text.
Application is running well on localhost but when I deployed the application on Amazon-ec2 instance it records blank file .
It doesn't show any error but it records nothing.
Can anyone help how to solve this?
`
def record(self):
time.sleep(2)
samplerate = 8000
duration = 5 # seconds
filename = path+'yes.wav'
print("start")
mydata = sd.rec(int(samplerate * duration), samplerate=samplerate,channels=1, blocking=True)
print("end")
print(type(mydata))
sd.wait()
sf.write(filename, mydata, samplerate)`
EC2s are virtual servers, not physical machines.
It is unlikely you would be able to record any meaningful data from audio inputs on an EC2 - your program is almost certainly waiting for input from the audio device but not receiving any, hence the empty file.
I want to send one POST request or GET request in a certain date and certain time say date is 1st feb and time is 2:00pm then request should automatically be sent at that date and time. Those date and time are stored in the database. What should be the approach for that?
I tried using django-cron but it runs only when i type python3 manage.py runcrons. i want it to run when server is running i.e after every 5 mins.
i followed this document. I previously didn't follow
> crontab -e
*/5 * * * * source /home/ubuntu/.bashrc && source /home/ubuntu/work/your-project/bin/activate && python /home/ubuntu/work/your-project/src/manage.py runcrons > /home/ubuntu/cronjob.log
now it is working properly.
I have a Ruby on Rails 4.0 and PostgreSQL app hosted in an Ubuntu VPS. in this application I want to send email based on data in the database. for example a background job check a table content per hour and depend on content send email to user or not. I decided to do this work by Resque.
how can I do that?
should I do in Rails app or in an independent service?
and how can I schedule this job?
There are couple of more options I advise you to try to
1. Cron : One of most preferred approach for any unix developer to run a task based upon some interval . here are read more about
FYI: if you facing problem with understanding cron settings there are gem available to do the same for you its called whenever
2. Resque-Scheduler : Surely you missed one of Resque plugins that provide exactly the same feature that you need its called resque-scheduler . It too provide cron like settings for you to work on
Please check the above link for more info
Hope this helps.
I do not use Resque because I want a process in the Ubuntu server that in a schedule time (per hour). for example per hour check the table content and send alarm to the users by email.
I make a process by Daemon and rufus-scheduler for scheduling.
Process.daemon(true)
task_test = TaskTest.new
pid = Process.fork do
task_test.task
end
class TaskTest
def task
scheduler = Rufus::Scheduler.new
scheduler.every '1h' do
msg = "Message"
mailer = MailerProcess.new
mailer.send_mail('email-address', 'password', 'to-email', 'Subject', msg)
puts Time.now
end
scheduler.join
end
end