Execute SQL job based on excel or text file message - excel

We have a SQL Server Agent job, which we need to run manually based on user/s request. The request is random and unfortunately, we cannot predict when the users will request it. Also, we have to it in after hours (Plus, it takes over an hour to run).
Anyways, I wanted to see if it was possible to run this job automatically based on a text file we can put on a Share drive. Users can update this file to say "Run" or "Stop" along with a few parameter values. I could setup a schedule to run daily and if the status changes to "Run" then the job runs for day/s until the text file is updated to say "Stop".

You can create and extremely simple small desktop for the user, where they can start Run/ Stop the job (simple C#, connect to database and execute job with the name of the job).
You can create a power shell script which will look for a file (text file) and depending on the value will run/stop the job.

Related

Power Automate - Infinite Loop issue

This sounds so simple in my head, but Power Automate doesn't like it.
I have a library with a lookup column. I have a Flow created which takes the filename of the document and puts this name into a "Title" column. Then I can use a lookup column on the Title column to find all the files in the library.
I've used "When a file is created or modified". Yet this flow runs constantly. No files are being update or modified at 1am, yet it still runs over and over. I've had an automated email telling me to fix this before it is disabled.
All I want it to do is run the damn flow ONLY when a file is updated or uploaded, just as its own function title suggested.
It would seem I need to add trigger rules, but all the guides I found were talking about checking if a specific person has modified it.
This used to be so simple with workflows, it would only run if something was modified or uploaded.

How to stop cron job after job is done programmatically

I am creating an app using magento 2 where user is supposed to upload csv file containing:
Name of base image
Name of clipart
height
Width
top margin
left margin
using above data I am suppose to combine both the images.
I am using cronjob to finish up this task, like as soon as user clicks on generate images first I am inserting all data into database and then using cron job, combining all the images after each minute.
The problem is cron job is still inserting data even after it has finished combining images. I want to stop cron job as soon as it finishes the task.
can I run cron job based on some condition or something?
The cron job always run by a schedule, so you have to add your condition within your code. Something like this:
if($this->isCombined()){
return false;
}
Cheers

Splunk - Finalize and delete current activity

I am using Splunk community edition for a monitoring dashboard.
I display a page of real time charts, I refresh the browser every now and then via a script.
This all works well however I am looking for a way to finalize and delete jobs running in the background as there is a limit as to how many live charts one can display in the community edition and when it refreshes the browser it seems to run to the limit after a while.
Thus how can I schedule the finalizing and deleting of the old jobs? (possibly a file I can remove from time to time)
I've overcame it by putting this at the top of my dashboard view (surrounded by XML tags):
< view autoCancelInterval="5" template="dashboard.html" >
The auto-cancel interval is set to 5 seconds. This means that when the search becomes inactive for 5 seconds or more, it will automatically cancel the search from running.

Setlocale in a cron job

I have a cron job creating dynamic files and sending emails to system users. I need to set the language within the cron job so gettext and date formats work when creating the dynamic emails.
I cannot set the LANG in the /etc/environment file because the language is not static. Lets say the cron sends 10 different emails to 10 users - each could have a different language.
When I run my script in a webpage where I can set the session variables with
putenv("LC_ALL".LANG);
setlocale(LC_ALL,LANG.".utf8");
Everything works great. I am guessing since the cron doesn't create a session, these are ineffective.
Any ideas on how I can set this variable dynamically within a cron?
Figured it out. I forgot to bindtextdomain. It is something that is automatically done on the website but I added it to the cron script and all is well.

Can Data Export from SQL Developer to Excel be scheduled?

I have to run almost 50 queries daily for daily reports and copy-paste the data into Excel sheets. Is there a way to schedule a job on SQL Developer that exports data from all the queries in an Excel Workbook?
You could link the excel spreadsheets to your queries so they automatically update themselves.
Insert > Data from External Source. I do this with SQL Server a lot, and you can do it with Oracle too if you know the connection strings.
I would comment, but I dont have the rep yet.
I would advise using your operating system to schedule the task. Assuming that this is Windows (as you want to write to Excel) then you can use Task Scheduler to set off a cmd script or powershell script which can call SQLPLUS passing in a parameter for the the sql file that you wish to run. It would not be too difficult to output this to a CSV file which can be opened in Excel. If you actually need to write the data to a .xlsx (or similar) file then there are options (e.g. Python libraries that can do this), but it will not be as straight forward.
I am not sure exactly what part of this you need help with, so can I suggest that you consider the steps below, if you want to proceed do some research and have an attempt at each step and then post a question for each that you are stuck on with details of what you have tried:
Schedule a job from your operating system;
Write a script to call SQLplus and execute a .sql file;
Change query output to csv and redirect to file (or find a way to write directly to an Excel file if this is what you need to do);

Resources