running scripts on ssh remotely - mysql

I have a python script and a file (both on ssh) to be inserted to a db (mysql) using the python script. My file has 53,000,000 rows to be submitted to the db. This submission takes a very long time. Is there anyway in which I can run the script so that even if I exit ssh the script continues running?
Thanks,

You can use the screen or tmux. Both commands allow you to have detached user session. You can reconnect at any time to this session.
You only need to start screen and run your scripts there. After that you can push ctrl+a and than d and your session will be detached.
To restore your session you need to run screen -a.

Why dont you have it handled in a jenkins pipline, setup a job in jenkins to run the script.

Related

SQL Server Job Using WinZip Command Line

I have a SQL Server 2008 Job that backs up a database, then zips that backup and moves the zipped file. My job runs fine until it gets to the step that calls WinZip, which executes:
c:\program files (x86)\winzip v19.5\winzip32.exe
-m \\RemoteShare\RestrictedFolder\dbBack.zip
x:\SQLInstanceFolder\BackupFolders\dbBack.bak
The job neither completes nor fails; it just stops moving forward. It will generate the dbBack.bak file and create the dbBack.zip file in the remote location, but it won't proceed past there. It seems to be behaving like it is waiting on a pop-up confirmation, but I don't see one when I log in to the console or run the zip from the command line.
I've tried adding -ybc flag to automatically confirm or skip any prompts, but it didn't seem to do anything. The process still didn't complete. I've even tried to > pipe output of the process, but it won't even write my log file.
This is a secured system and infrastructure, but I'm fairly certain I'm not being blocked by a permission. My SQL Server service account that runs the job has access to the folders it needs and it can run the winzip32.exe process. This process ran fine, but we had to upgrade WinZip this past weekend (19.5), and that's when it stopped working properly. We aren't able to roll back to the previous version (10).
Does anyone have any idea on what could be stopping my process or how to make it proceed?
I think I discovered the problem. It turns out, we are using the GUI version of WinZip and calling the executable from the command line. Even though we can't see the GUI, it's still there. So, the prompt to confirm our compression is still there in the program's workflow, we just can't see it and thus can't confirm it. And the confirm flags don't work with the GUI version.
My workaround involved logging in to my SQL server as our service account and running a WinZip operation. When it completed and gave me the Add Complete prompt, I checked Do not display this dialog in the future and clicked OK. This will suppress that prompt when the service account runs its Job.
If someone changes the service account, we'll have to do this again, so our ultimate solution will be to install the WinZip Commmand Line Plugin. Hopefully, when that's done, we won't have to worry about this.
But it works now. :-)

Easiest Way to Execute a Node Script

I have an AWS-hosted MySQL database with 900+ records. I've developed a Node script that queries the database for new records, generates MP3 files for each one, uploads those files to S3 storage, and inserts the links into my database.
Right now, I'm having to execute that script manually via command prompt (npm). The script only needs to be run occasionally, so running it manually isn't a problem. But I'm sure there's an easier way than command prompt.
Is there a way to automatically run the script every so often? Or perhaps run it via a desktop shortcut? I'm open to ideas on this...just looking to simplify.
I am very new to Node and all things programming, so please forgive my ignorance here.
In Linux, you could run as a pure Linux shell script. Use a cron job to schedule the script.
Ex :
#!/usr/bin/env node
console.log('Hello world!');
In Windows, if you want to run manually, you could create a bat file and run the bat file to run the script.
Ex :
name : my_node_script.bat
node c:\path\to\file\my_node_script_code.js
If you want to run the bat file periodically, you could use Task Scheduler to schedule the bat file. See this guide of you want more details on scheduling.

How can I automate mysqldump database backups in Windows Server 2012?

I'm trying to get mysqldump to do backups to a .sql file automatically, I have being reading that I need to use cron jobs or Windows Task Scheduler; the problem is that I can't find anything online that shows me how to do it.
To do the backups I'm using cmd with the following commands:
mysqldump --user username --password=123 databtable > backup.sql
This command works perfectly, it does create the .sql file but how do I automate it in such a way that it does the backup every certain time.
Hopefully you can help me and thank you so much!
You should use the schtasks command in Windows.
Command syntax details are available here: https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx
You could also use the Task Scheduler application in Windows if you like GUIs:
Create a new basic task
Set the Trigger (run daily, weekly, etc)
Set the Action. (what program to run) Be sure to
include only the executable in the Program field, and put the
command arguments in the Add Arguments field.
You probably want to set your task to 'Run whether the user is logged on or not'. This is achieved by modifying the task, and adjusting the Security Options on the General Tab of the task.
When troubleshooting your task, use the History tab for info regarding job failures.

Inserting with MySQL while in a scheduled task?

I am running MySQL on Windows 7. I use a scheduled task to insert a record into a table after an action has occurred. However, when the scheduled task runs, nothing is inserted. I have redirected output from the "mysql" line into a log file, but the log is always empty. Running the batch file manually does cause the record to be inserted successfully. The scheduled task runs under the same user account and priveleges as when I run it manually.
Has anyone seen this behavior before?
Never mind. Apparently despite being run as my account, "taskeng" doesn't know where "mysql" is. Writing the full path to the mysql executable solved it.

Bash init.d script detect that mysqld has started and is running

I'm working on my dedicated server running CentOS. I found out that one of my applications which starts up via a script in /etc/init.d/ requires MySQL to be running, or else it throws an error, so essentially I currently have to start it by hand.
How can I detect, in a bash script (#!/bin/sh), whether the MySQL service has started yet? Is there some way to poll port 3306 until it is open to accept connections, and only then continue with the script? Or maybe set an order so that the script doesn't run until the mysqld script runs?
The init scripts allow you to set the order with the numbering scheme.
Example, in /etc/rc.d/rc5.d you might see:
S98first
S99second
S99second runs after S98first due to the naming.