Is there a way to detect if a script is runned by a scheduled task.
I have a script which gives throws a ClientAbortException because I am using cfflush.
I need to detect if the script is running via a scheduled task so the script can run successfully.
It seems that you can check it via CGI.HTTP_USER_AGENT:
<cfif CGI.HTTP_USER_AGENT NEQ "CFSCHEDULE">
<cfflush>
</cfif>
This is a duplicate question as Travis said, but another answer is you could add a url parameter to the scheduled task something like ?auto= which would allow you to check the url scope to determine how it was ran.
Related
i have application for dailyhours for work,i just looking around about specific hour will be run script to check database if some value are None will be add value to database.
So my question is i need do this with some script with rest api or maybe django-celery will be okay for that ?
example:
start:8:00
end:12:00
daily:4:00
but sometimes if you forget close work you need change value for some workers in PA so i wanna create script which will be do it automate everyday if value are None
It seems that you need some background mechanics. I suggest two approaches
Django Celery. You can run periodic tasks with Celery.
Manually set up crontab. It seems easier option for your task. You can create management command check_db.py and run it via crontab like this 0 8,12,16 * * * python3 /path/to/your/app/manage.py check_db
I am looking for a way to execute a script at instance launch in Google cloud platform similar to user data in AWS. I check 'Startup script' but it is executed at every boot. is there any way to achieve it?
Yes, accordingly to the documentation startup script runs on each boot and there's no option available to change this behavior:
Compute Engine lets you create and run your own startup scripts on
your virtual machine (VM) instances to perform automated tasks every
time your instance boots up. Startup scripts can perform actions such
as installing software, performing updates, turning on services, and
any other tasks defined in the script.
To solve this issue you can use this workaround:
Set up a flag, such as a file on the disk, when your startup script runs first time.
Check existence of this flag in your startup script and exit without any action if the flag exists.
I am using Informatica and I want to auto run the failed session. How can I achieve this?
I tried it by enabling Auto recover terminated task property in workflow. But it is not working. It is not being rerun on failure. Anyone can help?
There's no such out-of-the box feature. But there can be many solutions:
Ideally you'd use a separate tool / script to run the workflow, check it's state and re-run if failed. This can be achieved using second workflow with a command task, for example, but:
Why don't you try to resolve all the issues and make sure the workflow runs successfully?
Yet another option would be to have a touch command executed in case any session in the workflow fails, and have a second continuously running workflow with event-wait that executes the first workflow if the specified file shows up.
I'd like to execute a script before I execute any project/build on a Jenkins server. I've checked out the BuildWrapper script and a couple of others.
These all seem to be based on a specific job, but I'd like to get this sorted to work across any job/build on this server.
You could add an upstream job that all jobs depends on.
Specifically, In the buildsteps of your job, you can choose "Trigger/Call builds on
other projects", add ParentJob and select "Block until the triggered
projects finish their builds" before invoking the buildsteps of your job.
In my django project I would like to be able to delete certain entries in the database automatically if they're too old. I can write a function that checks the creation_date and if its too old, deletes it, but I want this function to be run automatically at regular intervals..Is it possible to do this?
Thanks
This is what cron is for.
You will be better off reading this section of the Django docs http://docs.djangoproject.com/en/1.2/howto/custom-management-commands/#howto-custom-management-commands
Then you can create your function as a Django management command and use it in conjunction with cron on *nix (or scheduled tasks on Windows) to run it on a schedule.
See this for a good intro guide to cron http://www.unixgeeks.org/security/newbie/unix/cron-1.html
What you require is a cron job.
A cron job is time-based job scheduler. Most web hosting companies provide this feature which lets u run a service or a script at a time of your choosing. Most Unix-based OSes have this feature.
You would have better direct help asking this question on serverfault.com, the sister site of stackoverflow.