timer for shell startup script - shell

I am instanciating a machine on the cloud with a startup shell script (on ubuntu) which basically download some config files and run a python script. I would like to include some kind of security on the startup script which should reboot the machine 10 minutes after the startupscript started, and which is totally independent from what the startupscript is executing.
What would be a very clean way to do so?

Related

Apache Guacamole starting intial wine program

I am trying to setup a remote desktop using Apache Guacamole on Ubuntu 20.4 but I only want the initial program accessible to the user. The program is a Windows program and I am using WINE.
So far I have tried invoking wine via a bash script. And then placing that script path in the initial program settings in the connection settings of Apache Guacamole.
The initial program path looks like /home/frank/launchprogram.sh in the guacamole connection settings.
The launchprogram.sh bash script looks like below. I simply copied the command settings in the shortcut that is on my desktop. For simplicity I have it chmod 777.
#!/bin/sh
env WINEPREFIX="/home/frank/.wine" wine C:\\windows\\command\\start.exe /Unix /home/frank/.wine/dosdevices/c:/users/Public/Desktop/myprogram\ V4.lnk
The above script works fine from the terminal when on the desktop. But not with Guacamole.
I have also tried in the bash script
WINEPREFIX="/home/frank/.wine"
wine "/home/frank/.wine/drive_c/Program Files/myprogramfolder/myprogram.exe"
and it doesn't work.
If I simply put
wine myprogram.exe and run it in the same directory it works. But not in others.
What am I doing wrong?

Microsoft Azure Backup (MARS) not running from scheduled tasks

We've got several servers running MAR's the lastest version 2.0.9145.0
I can run all backup's manually and its runs without problems. But when i try to run it from scehduled backups it shows in task scheduler that its run but gives this error code:2147942401
If i manually input the arguements into powershell it runs fine. However the task scheduler is not kicking in the backups.
I've altered the permissions to a domain admin, changed PS path to syswow64. So now i'm lost.
Has anyone had similar and any ideas on how to fix it or at least run the commands from a bat file instead?

Starting jenkins Slave agent using Jnlp using Task Scheduler always starts as headless

I am trying to find solution for the jenkins nodes to automatically connect to master in non headleass mode.
Here is what I have done so far
I have written batch script which calls the powershell script. Powershell script has series of commands to start the jenkins slave agent using jnlp.
This batch script is configured in Task Scheduler to run at the startup. The jenkins slave node is connected to master as soon as node starts up.
But execution of GUI test is not visible in the node when the test starts.
When I manually run this batch script from command line, it works fine i.e non headless mode and I can see the execution of GUI test.
I've read few articles about this kind of setup and none worked.
I also wrote a small piece of powershell script to allow a Windows Service to Interact with Desktop. This script runs after the batch script to start jenkins slave agent.
Task scheduler job is configured to Run as Administrator and I login as administrator to see the execution.
Since this batch script is running via Task scheduler I am guessing its running in a different session.
How do I solve it.
Try to put your script into shell:startup.
On a Windows 10 machine with the Jenkins slave under the user you need, press Windows+R (Run...) and type shell:startup and put your script into opened folder. It will run once the user logged in.
This is how you'll see console and any windows it spawns.

Jenkins job windows batch execution 20 times slower than executing in cmd.exe

I just installed Jenkins 2.46.2 on a Windows 2012 Server \o/. It runs as a system service.
I created a job that execute a windows batch (.bat) script to build a code project. This batch results in executing 2 mingw32-make.exe commands to clean and then build a full binary from source code.
Executing the batch manually on the machine, located on the same filesystem (same workspace as used by the Jenkins' job, local disk - not network disk), the clean-build takes ~50 seconds.
But when executed by Jenkins, the job takes more than 20x more time longer! (~19 minutes). It terminates succesfully with the same behavior as executed manually in cmd.exe.
I changed the launch arguments for the jvm in the jenkins.xml file with "-Xmx1024m -XX:MaxPermSize=512m" options as I have read in the documentation to improve performance. But it does not fix anything :-(
Also when I monitors the CPU/disk/RAM usages they all stay very very low while building, so I deduce that brute performances of the machine are not in cause.
Whether I invoke the batch with call statement in the Jenkins job build step or not does not change anything : the job always last 19 minutes.
Can anybody help me to investigate why so slowness ?
Thanks in advance :)
I had a similar problem. I noticed that .bat files with echo Hello World ran fast and with no problem.
But once I tried to launch any grep.exe from a batch script, it took 24 seconds (in my case) to run even with no input files. If launched manually it finishes in no time.
I used grep.exe version 2.5.4 from MSys 1.0 distribution.
The solution in my case was rather unexpected - I updated grep to version 2.24, and now, being launched from Jenkins, it takes less than one second to process over 1 MB log file.
For a couple of day investigation, I finally find the cause.
In my case, it is the reason of Jenkins agent.
When I install Jenkins agent as a windows service in the slave agent, the consuming time is so huge,but when I try to start Jenkins agent via windows command line, the consuming time is as normal as executing the batch file manually.
My env:
master: CentOS7
slave agent: win 7
And I also test this case in a slave agent of win 10 for comparison.
The time executing via Jenkins is approximately the same as executing the batch file manually on the agent machine.
So I guess this is the compatibility issue between win 7 and Jenkins.
But for that the Jenkins official said that Jenkins not support win 7 anymore (Microsoft does not support Windows 7), we temporarily put it aside.
Anyway we find a way to conquer this. Hope this will help you for similar scenario.

run batch script after windows server restart

I am trying to run a script to startup some services after windows reboot.
I have tried one method: copying shortcuts of batch script in shell:startup folder. which eventually will start the scripts automatically but someone has to login to the system.
I am thinking about the possible ways to run the script after server restart without logon to the server.
Any help will be highly appreciated.
Create a Windows scheduled task and set it to run on system startup:

Resources