Launch a command on a server while a job has been launched with cron - server

I am wondering if I could launch a command on a server using the server terminal without interfering with my cron job that was launched automatically 1 hour away ? The server is an ubuntu, distant, with few resources, and I am communicating with it on PuTTY.
And second asking, do you know a command to check the amount of resources used by my running cron ? This is the command I would launch on the server right now.
Thank you in advance for your help,
Valentine
PS : for the moment, I didn't try anything because it is really important that my process running with a cron succeed.

Related

The HTTP request to the remote WebDriver server timed out after 60 seconds. Happens only when running through the task scheduler

I'm troubleshooting an Selenium script that runs through the Task Scheduler on a Windows Server. It's running in PowerShell using version 3.0.1 of the Selenium module (found here:https://www.powershellgallery.com/packages/Selenium/3.0.1) with the Edge browser (the one with Chromium).
The "The HTTP request to the remote WebDriver server for URL [localhost] timed out after 60 seconds." error has been quite persistent and only appears when run through the Task Scheduler. The script runs fine when running manually through ISE.
Also to note, there's another script that is more or less the same as the one having the issue, albeit using a slightly different url (same site). This second script runs without issue through the task scheduler. They're performing the same sequence of actions which is why I'm not entirely sure why it would fail for one script but not the other.
I haven't found a suitable solution while looking at other posters facing the same issue. Any help is much appreciated!
I had the same issue. I tried all kinds of code changes but the only step that worked for me was to change the Security Options in Task Scheduler.
Task (right-click) > Properties > General > Switch from Run whether user is logged on or not to Run only when the user is logged on.
I guess this would be a temporary solution. I'll keep looking and update this if I find a better solution.

Running Flask at startup as a Service in Windows won't work in background

Before explaining what my problem is, please know that I have looked up for solutions on similar topics but none of them seems to work nor even to corresponds to my problem.
What I am trying to do:
I have this python code on multiple files that I run with flask with the following command:
python -m flask run --host=0.0.0.0
So far, everything works, but I would like this code to automatically run everytime the computer boots. In the future this will be used on mini PCs without any graphical interface nor human intervention.
Since I need to do some configuration checks before running the web server, I've created a powershell script that ends with Flask running (using the previous command).
So far, everything works too. Now we're coming to the problem:
I'd like this script to run when I boot the machine. Specificity: Every things needs to work with Administrator privileges, on the local system without any interaction.
I've tried scheduled tasks but Flask won't run even if the rest of the script works (like creating folders or other things)
Ok, it's not a big deal I have other ways to do it, so I've created a Windows Service in C# to run the Script at startup on the local system.
The script works, I've checked the privileges too, everything's fine but arriving at the flask command line that is supposed to make it run, nothing works.
It's the same thing if I run flask using "pythonw" which is supposed to run python as a background process.
What the problem seems to be:
Well, as long as I run flask and I have either a command prompt or a powershell terminal, everything works greats. But if in a way or another I run the script as a background process, it won't work.
Normally it would take around 30 seconds for Flask to start-up. Here if I try to create a folder right after flask ended starting up (as a test) I can see the folder is created almost instantly, which means the process is immediately killed.
The problem doesn't seem to come from the service itself but really Windows that kills the process I don't know why
I'm running out of idea so if you guys have anything that I could try it would really help me.

How to restart an exe when it is exits in windows 10?

I have a process in windows which i am running in startup. Now i need to make it if somehow that process get killed or stopped i need to restart it again in Windows 10?
Is there any way. Process is a HTTP server which if somehow stopped in windows i need to restart it. I have tried of writing a power-shell in which I'll check task-list status of process and then if not found I'll restart but that is not a good way. Please suggest some good way to do it.
I have a golang exe; under a particular scenario my process got killed or stopped i need to start it up again automatically. This has to be done imediately after the exe got killed. What is the best way to achieve this?
I will give you a brief rundown. You can enable Audit Process Termination in local group policy of the machine as shown below. In your case, success audits would be enough. Please note that the pic is for Windows 7. It may change with OS.
Now every time a process gets terminated, a success event will be generated and written to the security eventlog.
This will allow you to create a task scheduler that triggers on the generation of this event that calls a script that would run the process again. Simple right?
Well, you might have some trouble setting that task up especially when you want to pass details about the generating event to the script. This should help you get through that.
You can user Task scheduler for this purpose. There is a option of "restart on failure" which can be selected and whenever your process get failed it will restart again.
Reference :- https://social.technet.microsoft.com/Forums/windowsserver/en-US/4545361c-cc1f-4505-a0a1-c2dcc094109a/restarting-scheduled-task-that-has-failed?forum=winserverManagement

Reliable access to locked remote computer

What I have: I have Windows 7 on my home PC.
What I'm trying to do: I'm trying to keep TeamViewer running at home so I can always get to my home computer. The other day it got completely messed up and would not let me connect but everything else on the PC was just fine.
Items I've looked at:
I looked at this thread and it does not seem to apply to what I need:
Is it possible to start Teamviewer, to accept connections, from commandline?
... but it does not appear to be what I'm looking for.
I have looked at this:
https://serverfault.com/questions/48600/how-can-i-automatically-restart-a-windows-service-if-it-crashes
... and to test the script at the above URL, I stopped a service on my computer and pointed the above vbs script to that service and the vbs script will not restart that service, so that's not working.
What's happening:
From time to time on my home computer, TeamViewer hangs or gets messed up in some way and I cannot connect to my home computer. The last time this happened, the TeamViewer UI was still running but there was a little red dot next to the tray icon and the id numbers and password were blank in the UI so I had to right click and kill it and restart the computer and all was OK.
What I'd like to do:
Is there a way I can run some kind of script or something that will completely kill all TeamViewer processes and services and restart it completely? I'd like to schedule this type of activity once an hour so I can be assured of pretty much always being able to get into my home computer or else just wait an hour and it should be back up and available?
I have 20 years in IT with networking background, databases, GUI development, website development, hardware and software installation but no experience in brain surgery. I've given it a good try but am now asking for some help.
Thanks.
I think that task scheduler, taskkill and batch script is your friend here.
create a batch file to stop any current team viewer process and then restart it.
crate a batch file something like:
taskkill /IM TeamViewer.exe
start "" "C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
(substitute the path to TeamViewer.exe on your own machine).
Then create an hourly scheduled task to run the script using the highest privileges (using Windows Task Scheduler).
Lookup taskkill for more info on killing tasks from the command line.
Just to add that you'll have to have the PC in a associated in your teamviewer account in a group (e.g. My Computers) and use the same account to connect - otherwise the password change on restart will prevent you connecting (you won't know the new password).

How to check user ".profile" exist or not before running crontab in Solaris 10

I am using Solaris 10.
I have another user apart from root say testuser, which is mounted in NAS file system
I have some script which need to be run as testuser. so I had added them to the crontab of testuser.
As long as NAS is up all the cronjobs are rqn properly, but when NAS goes down then cron itself crashed by giving ! could not obtain latest contract for PID 15621: No such process
this error.
I search for this issue and came to know that because it's .profile file is not accessible due to which it is giving this error. So is there any way by which we can check user specific .profile file exist or not before run any schedule job
Any help on this will be appreciated.
I think a better solution would be to actively monitor the NAS share, and report an error (however errors are reported at your location) if it isn't. You can use tools like nfsstat to get statistics on the NAS share (assuming this NAS share is mounted via NFS). It seems a better solution than checking to see if it's working before running cron -- check to make sure the share is available, because if it isn't, attention is needed.
Cron doesn't depend on anything but time, so it will run regardless of whether or not the user's home directory is available. If the script that the cron job is running is local, then you could prepend a check to make sure the home directory is available before running, otherwise just exit with an error code.
If the script that cron is attempting to run is in the user's home directory, you're out of luck, because an error will occur in even trying to run the script to check for the existence. You will need to check the status of the NAS share before attempting to run the cron job, but the cron job will run regardless. See where I'm going?
Again, I would suggest monitoring the NAS and reporting when it is failing.