Remotely restart a linux service from local Windows or Mac machines - service

Sometimes my media server does not update its database, the only way to fix it is to restart the daemon.
I would like users to be able to simply run an executable or script to do so without revealing any login information to them (which might result in inadvertent headaches).
I feel the easiest way to do this would be to have an executable/script located on a samba share which they can run. The users would be running Windows or Macs which are all on the same local network as the server.

Write up a small CGI script or web app that has a button that when pushed restarts the daemon.

You just need some communication between a privileged daemon (or frequent cron) and the CGI script. Have the CGI script create a file, if the daemon or cron finds it have it restart the service and unlink the file. Primitive, but effective.
As Ignacio said, there are many, many lightweight HTTP servers that support CGI.

Related

How to get over my Valid Application from being repeatedly Blocked by Firewall

I use Delphi. I have a backup application which has to run constantly on my customers machines. Communicaton is done via TCP/IP Sockets & data is transferred via FTP.
My problem is that sometimes when the customer upgrades his AntiVirus or I send a upgrade the Firewall blocks my Application even though setup was done via elevated rights. How do I overcome this. I had thought running my communication portion from a Windows Service Application would solve the matter.

Linux/CMD environment and terminal on website

I am looking for a way to incorporate a command line interface into my website. Specifically I have 2 servers, one running Linux distro and the other Windows. People can request accounts and if I approve them they get a user partition on either of the servers.
They can then sign in on the website and access the servers through a command line interface. I saw a couple of repos that do something similar for the Amazon EC2 servers but was wondering if there is anything more general?
You can use shellinabox. This runs a daemon on the server and can be accessed through a specified port. You simply have to enter the IP of your server and the port number and you can log in over a browser.

Is it possible to run matlab on a remote server and control it using the matlab GUI from a thinclient?

Akin to what can be done with emacs with slime: the core services can run on a performace grade remote computer while I can edit and run code from emacs gui on an netbook.
Me and my colleagues often need to do some demos using machine
learning scripts running in matlab
This requires us to carry around heavy laptops.
Could we have the applications running on a remote server and access
it using the same matlab gui without running the scripts locally?
Remote desktop or similar solutions are not acceptable: multiple users would like to use the same server.
This is why none of the answers here were helpful
In my experience, the best way is with VNC. You can start a VNC server on the host machine, and then access this desktop remotely from anywhere with a VNC client. You can disconnect and reconnect at another time, and your desktop will still be there. Also, multiple users can all have different sessions going, or can access the same one. If you don't want each session to run a full blown desktop, you can configure it to be minimal. For security, it is recommended to use an SSH tunnel or similar.
The exact programs will vary based on your setup, but the things to google are bolded, above.
My setup is:
VNC server: vnc4server on a Ubuntu linux host.
VNC client: Chicken of the VNC for mac.
SSH tunnel: SSH Tunnel Manager for mac (although this can be done at the command line too).
Good luck!
EDIT: Here is a screenshot of a vncserver session I just started up on our cluster, with matlab running in it. I'm accessing it through the vnc client on my mac. Works great!
SSH with X-window forwarding will do the trick. It will get you the MATLAB screen you know and love but will be running everything on the remote computer. To do this, in a terminal with SSH (I like MobaXterm, though you can use Putty) you ssh via
ssh server.location.here -X
This will get you the terminal on the computer (after typing in a password), and in the terminal just type
matlab
and a MATLAB screen will show up. Note that opengl will be disabled, so your plots might not plot as fast, though you can still use gpu algorithms (i.e. cuda. Note you may need to run the command "COMPUTE=:0" before opening matlab if gpuDevice turns up empty for MATLAB's cuda).

perl-cgi script slowness

I have a perl-cgi script which is log to cisco devices and run a command. so recently move the script from old solaris server to the newer more powerful vm server. now the script is very slow to log to the device actually got timeout. I am not expert on perl and I don't know how I can troubleshoot.regarding of the network there is no issue detected upon my test. as I said the server and the network at least 10 x faster than the old one. any suggestion? thank in advance.
The script was probably written using blocking sockets. The fact that it moved has probably slowed down the connection between the cisco devices and the server running the CGI. I would check your network path first. If this is still a concern you should write this to fork() a child process, use non-blocking socket techniques or write a CLI app. This doesn't sound like something that is well suited to run as a CGI.

How do I know if a system has powered on?

I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on?
My programming language is Perl and the target host is RHEL5.
Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded?
[In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and when is the OS is supposed to have booted completely for a network related operation such as executing a network command there. What if the system is on DHCP how would a remote system then search for this machine [i guess it is possible via mac address. but if i am wrong ].
If I have missed out any info please feel free to ask me. If you have any suggestions to make the task easier please surface them :)
thanx
imkin
Well, I'd say the system is booted when it can perform the request you've made of it. That is, the sshd daemon is running. That's booted sufficiently for your purposes (I assume - substitute for whatever daemon you really need).
So, I'd send the power-on signal, and check back every 15-30 seconds to see if I could connect. If I've failed to connect within whatever is a reasonable time for that machine (2 minutes or 5 minutes or whatever), then I'd send an alert to the IT support team. Well, I'd send it to myself first, and only once I've investigated a few failures or so and found them to all be legitimate would I start sending it directly to IT.
DHCP is kind of a different question. You'd have to start learning about broadcasting, or having a daemon on that machine "call home" during boot to register its current IP address. And it would have to "call home" every time a DHCP renewal changed its IP address. This is decidedly more convoluted. Try to avoid DHCP on such server machines if at all possible.
On the rebooting machine you can install a script in your crontab with the special #reboot assertion (see man 5 crontab). That script could send a notification of some kind to the other machine, notifying it that it's up now.
I think checking for sshd sounds like a good approach.
As for the DHCP problem: if the other computer is on the same subnet you can look it up by MAC address using Net::ARP.
How about adding a script to the remote machine which gets run on startup to have it tell you when it is ready.