Is it possible to write a daemon to do cleanup on Parse? - ios

I am working on a snapchat clone to get familiar with parse. I was wondering if there was a way to write a script that runs at predefined intervals and deletes messages that are over 24hrs old.

You can write a background job (https://www.parse.com/docs/cloud_code_guide#jobs).
Next you schedule the task every 24 hours.

Related

Telegraf, trigger at start and not interval?

Hello i am currently trying to parse a folder of many csv Files(ca. 3GB) into influxdb.
On the influxdata blog it was suggested, that this would be the fastest way since telegraf is written in go.So:
I can get everything to work and i can parse all csvĀ“s and write them to influxdb.
The Problem is that parsing and writing the files takes a lot of time (old macbook..more than an hour i think) and when the agent interval is smaller than the time it takes to write the data, telegraf-agent will start again to read and write all files at the next interval. So it never finishes and my ram gets packed with all the same parsed data over and over. When i set the interval really high i have to wait one interval before the agent starts. So not an option too.
The question is:
Can telegraf be triggert like a script? So that i just run it one time and not have to wait for one interval to start?
The functionality you need has been added since this question was asked. You can now run Telegraf with a --once flag.
I can't find it documented anywhere, but the commit is here.
It's available in v1.15.0-rc1

Jenkins results: Need a "single" summary report of last run of jobs

We have multiple jenkins-jobs scheduled at roughly near the same time every night.
I would like a report-summary of status to be available to me / or sent to me.
I do not repeatedly want to do a walk through test suite every day.
Much appreciated any advice on topic ?
The Global Build Stats plugin might fit your needs. It does not support scheduled email, but if you need that you could use the rest API it exposes to write your own.

Ruby on Rails - Automated Email Sending - Flight Reminder

I'm creating flight booking website in Rails. Booking information is stored in database in the following table:
USERNAME | FLIGHT FROM | FLIGHT TO | DATE OF FLIGHT | TIME OF FLIGHT | some additional information not relevant to this task ... |
I'm looking to send an email an hour (or some specific time) before the TIME OF FLIGHT on a DATE OF FLIGHT. What is the best approach to do it ? I was looking into Cron and delayed_job however both seem to be based more on intervals rather than executing a job at specific date and time.
Please help.
Thank you
The simplest approach is just to have a cron job set to run every 10 minutes and determine via a database query which flights now require a reminder e-mail. You can have an additional field in the database such as "REMINDER_SENT" so that you only send an e-mail once.
If you are already using delayed job then the cron job should just call a ruby script which adds a SendReminders job on to the queue. You can then manage all of the db querying, e-mail sending and db updating from a normal delayed job.
This approach saves you having to queue up a large number of future dated events and you don't need to worry about flight times changing or events getting lost. If you miss one event then the next run in 10 minutes will pick up all the flights anyway.
Are you required to send those notifications exactly one hour (or another time) in advance?
If not I would create a cron job that calls a rake task, say every 10 minutes. This task checks if there are notifications due and sends them. If you expect them to arrive 60 minutes before, with these settings you have a delivery timeframe between 60-70 minutes in advance, given the delays imposed by spam filters etc I think this is reasonable.
If you call the script more often (every minute), the precision is higher, but you might have trouble with concurrently running tasks.

Email notification when 'updated_at' become 2 hours before current time

I'd like to make an email notification if SomeModel has not been updated for 2 hours.
What is the best way to implement it?
After a model has been saved, queue up a background job to run 2 hours from that time to send the email. When a new job is enqueued, remove any still-unrun jobs that are still on the queue.
resque-scheduler providers a pretty simple way of doing this, assuming you have redis up and running.
Personally I find the solution that #x1a4 proposes to be somewhat overkill. Given the relatively large window of 2 hours, I would just run a job periodically (say, once every 10-15 minutes), then search all Models for updated_at <= 2.hours.ago and send out the emails.
As for scheduling that job to run every 15 minutes, there are several options. You may use resque-scheduler, if you are using Resque. You may also use the standard system cron, but will incur some fairly substantial overhead starting Rails each time the job runs. I also have written a distributed scheduler gem (i.e. cron that can run on multiple machines, but act like it's only running on one), which uses Redis under the hood.

Need to run a job at a specific time

I'm trying to create a job in order to send a notification to a Twilio call, therefore it is important to have a robust solution that can make sure jobs are run at a specific time (I don't think being put into a queue is accurate enough).
What is the best solution for this type of a task?
These notifications need to happen at a specific time in the call. Such as "1 minute left". Therefore it needs to be able to:
Run at arbitrary times (1:22PM or 2:45AM)
Be defined by user input (they set the time of the call)
(It would be nice if that solution could run on Heroku)
You can use Heroku cron to run jobs either daily or hourly.
Daily cron is free, hourly cron costs $3/month: http://addons.heroku.com/cron.
Typically cron runs when you first initiate it (i.e. if you set it up at 3pm, it'll run at 3pm every day), but you can change that by sending an e-mail to support#heroku.com.
To run code in a cron, add your code to a cron.rake file and check out the cron docs here.
FYI
Heroku's own samples for cron suggest doing a time check, i.e.
if Time.now.hour % 4 == 0 # run every four hours
...
But, if you are running a daily cron, the code will run at a time that is likely to fail the above conditional. So, unless you are paying for hourly cron and you only want it to run specific hours, leave out that part of their sample code and just include your own code normally.
Running at Specific Times
Try delayed_job's :run_at column, which may give you the flexibility you need to run jobs at very specific times.
Heroku Docs: http://devcenter.heroku.com/articles/delayed-job
You need to add a cronjob for that. If you are on a Linux box then you can add a cron to the crontab and specify the time at which it runs. It is very flexible. You can find the details here:
http://en.wikipedia.org/wiki/Cron
If you want to do it in a ruby way, try whenever gem:
https://github.com/javan/whenever
For the specific case that you have mentioned, I think that you should give delayed_job a try:
https://github.com/collectiveidea/delayed_job#readme
it has a run_at option where you can specify the time at which you want to run the job.
Goto cron jobs in your hosting control panel

Resources