How does Delayed job work in ruby script - cron

I want use delayed job on ruby script (not rails) but i can't find anything in delayed Github page or wiki page
I want use a background job gems on ruby script like resque , delayed job , sidekiq or etc.
how start background process on ruby script without rails ?

Related

changing slurm bash script after submission (I want to change the script for a queuing job to avoid resubmission)

I have submitted several bash scripts to slurm in a school cluster and there is a long queue. By some chance, I found I made a typo in one of my scripts in a dependence chain. If that is possible to modify the script without canceling the job and resubmission?

Kill a certain httpd job

We have a CentOS server that runs our PHP scripts.
Sometimes when we start a script from a browser and the browser is closed the job keeps running on the server.
Is there a way to kill that particular job ?
On the server I can see a bunch of /usr/sbin/httpd jobs running, but how do I know that is the job that was started in the browser, so I make sure I'm not killing some other job ?
It would be useful if you provided details of the particular jobs that are being started by the users.
Its difficult to know which thread the script is running on, It would probably be more effective to set your max_execution_time in your php.ini file to something suitable.
If you are getting zombie processes, you could try something like the solution to this other question on SO:
bash script to kill php process older then an hour
There are other options available depending on what the scripts are doing, but it's difficult to say without knowing what it's doing

Jenkins to monitor external cron jobs

We are using a dedicated Amazon Ubuntu ec2 instance as Cron server, which executed 16 cron jobs at different time intervals i.e, 10 cron jobs in morning 4:15 - 7:15 and the rest # 23:00 - 23:50. I get the results via email. I want to configure something, which shoots email message at the end of they day listing the cron jobs that are executed successfully and the one that failed.
I have a jenkins configured ubuntu instance for auto-building Dev, Beta, Staging & Live environments. Can i add these cron jobs(shell scripts) as external jobs in the jenkins and monitor them. Is it possible?
Definitely possible! You can monitor external cron jobs as described here:
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs
You can also add cron job (-like behavior) to Jenkins by creating a freestyle software project and add "Execute shell" as build process.
It's a bit more convenient since you can also trigger the execution via Jenkins ("Build now").
You might be able to combine the Jenkins monitor external job project type with a matrix project. At the very least the former will enable you to monitor the cron jobs individually.
Alternatively you could have the last monitored cron job of the day trigger building a project that checks the status of all the cron jobs (for example by retrieving and comparing the build numbers of the last and the last successful builds) and sends an email accordingly. The email plugin might be useful for the latter.
Check the CPAN or do some web digging for shell or perl script for managing cron jobs and extend its behaviour to do some reporting which you can render using HTML. Alternatively write a servlet and a some function calls to do just that.
This becomes your own standalone monitor application, which can sit in jenkins or deployed independently. If you choose to add it to jenkins, then add the reporting HTML file and its scripts to the container holding deployed web files for jenkins, word of advice place your files and script in a separate container.
Add a hyperlink to jenkins index html which will load your reporter. Now reboot tomcat and go from there.
Another option could be to take a look at Cronitor (https://cronitor.io). It basically boils down to being a tracking beacon that uses http requests to ping when a cron job/scheduled task starts and ends.
You'll be notified if your job doesn't run on schedule, or if it runs for too long/too short, etc. You can also configure it to send alerts to you via email, sms, but also Slack, Hipchat, Pagerduty and others.

Is there a limit excution time when I run a PHP Script by Cron Jobs?

Is there a limit excution time when I run a PHP Script by Cron Jobs?
For example, I need to backup my big database file through a PHP Script. I set a cronjobs which automatically run everyday.
My question, will the php script run until everything is ok?
ini_set("max_execution_time", "0");
ini_set("max_input_time", "0");
set_time_limit(0);
How I usually set up my cron job scripts is to simply printing everything (especially errors or exceptions) to standard out. To my experience most cron systems will then email the output of the script to whatever local user is running the script. I then have that mail forwarded to my work account to notify me that the script ran and if there were any errors. For basic maintenance scripts that run daily or weekly I've found this to be a quick, effective way to keep me updated on their status.

Run program in background, constantly, on a web server - preferably in PHP

I want to create a website application, that will allow our members to get text message/email alerts every day 1 hour before their lesson (a reminder).
My server-side language background is strictly in PHP (although I've tampered some c++ back in the day). For this to work, obviously, I'll needs to somehow run a program constantly on my server.
Can this be accomplished in PHP?
If yes, is php efficient at this?
If not, how can I do this?
Or, maybe, this an entirely wrong approach, and there's a better way of creating such a service.
yes, u can consider make PHP as a daemon
or check this out php execute a background process
or simply use cron - http://en.wikipedia.org/wiki/Cron
but you should NOT create a web service/application just to run background PHP processes, it should cater for complex job
Sure, you can use PHP as a scripting language on the server. It's just as capable as any other.
Write a PHP script that checks your database for what members need to be alerted, then sends the message. Add a crontab to run this script every minute/hour/whatever. To run a php script from the command line, you run the php interpreter and give it the script name to run.
$ php /path/to/script.php
You would have to start a service on the server itself or create a CRON job to run at any given interval. If you don't have admin privileges you will have to do a CRON job, which can usually be setup in your host's cpanel.
For instance, you could create a small PHP script that
1) Searched for all lessons that start in the hour proceeding the current hour. So if the script is run at 5pm it would search for lessons that start between 6pm and 6:59.
2) Send an email to those members.
It wouldn't be exactly 1 hour though.

Resources