Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm trying to setup an alert to let me know via email (SMTP) when free disk space on one of my servers is less than a specified value. To do this I'm using PerfMon alerts, as described at MSFT Technet. I have the alert working and writing to the system log, but when I try to set it to 'Run Program' it fails. The log alert fires but the program fails.
The program I'm using is a small C# app I wrote to send an smtp email. I have tested the app independently from this server, running it manually and it works fine, without any user interaction (console app). But when I have it set to run via the alert trigger it fails.
Could it be that you have no command line arguments for your program?
I found the following on http://support.microsoft.com/kb/324752/en-us
When an alert occurs, the service creates a process and runs the specified command file. The service also copies any command-line arguments you define to the command line that is used to run the file. Click Command Line Arguments, and then click to select the appropriate check boxes to include the arguments that you want when the program is run.
Note You must select at least one command-line argument or the program will not run. (This is true regardless of what program you have selected.)
Do you have some kind if exception handling/logging in your C# app? Do you get anything from it?
Could you put your C# app call in a batch file and start that from the alert? If you add something like
echo %date% %time% > log.txt
at the start of your batch file you could see if it started at all.
Did you set the Run As field in the alert properties? If not, your program is being run as a LocalService, which does not have network access (among other things).
Try setting it to a user account under which you were able to verify that your program works correctly.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
Every time I turn off Putty after I write:
sudo node server.js & (after getting the process started)
a few seconds later it shuts down the website.
and than i see that it had deleted the process...
what can be the reason?
ok i need to add some information: it happens only after i fill a form of nodemailer and send it to the server.js, then it kills the process and everything shuts down. the form is the trigger not anything else!
When the SSH session ends (disconnects) it kills the process.
It sounds like you need forever or nohup or my personal favorite PM2.
Forever: https://github.com/foreverjs/forever
PM2: https://github.com/Unitech/pm2
It's most likely an issue with your server.js (or mailer) code. I've been running a node program as a background process on ec2 for quite a while...
--------------------------- edit ---------------------------
You would need to use nohup or another longer term service to maintain the program binding after logging off.
I would suggest you look into something like Screen. It is a window manager that allows you to detach a shell, but still keep a process running in it. That would avoid nasty log files and stuff like that, plus it can be easily reaccessed.
I'm fairly new with Linux shell scripting but have several years experience using Linux(non-hardcore).
There is an application running on my server(accessing it through SSH/putty) which is a console one. In order to ensure that it will run even even if I close my ssh client(putty), I made it run though screen.
In my script, there is a part where I want to enter this specific screen and "leave a message", then leave the screen to proceed with other things it have to perform.
How to do it exactly? Thanks!
(the console application is actually a vanilla Minecraft server)
check out 'screen' window manager http://www.gnu.org/software/screen/ with session names, see the following article:
http://www.mattcutts.com/blog/a-quick-tutorial-on-screen/
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a WHM server running Centos 4 (yes I know it just turned unsupported) all updates are installed, everything seems up to date.
In Dec 2011 one of the server owners, who has like 50 websites on it, got his computer infected and the virus/trojan read his FTP saved passwords then logged in by ftp and modified ALL index.php files it could find, we though we cleared all.
The problem is the following, they're somehow sending e-mails using a perl script fired by Apache I need a way to find out which is the path of the script they're firing, in "ps" it only shows as "perl", when checking the files opened by the perl script it lists ALL apache vhost logs, apache error log and /dev/null.
I NEED a way to find out the path of the script that's sending the e-mails, the server got listed into CBL at spamhaus twice by now, searching "by hand" it's not an option as there are over 200 websites there that take over 100GB of space on the server.
Server it is NOT compromised, the only problem is that I can't find the script that sends the spam.
You can try and figure it out from the /proc directory
Grab the PID of the running perl process, then check
/proc/PID/cwd which will be a symlink to the current working directory of the script
check
/proc/PID/cmdline which will contain the full command line of the running process
(in both those cases replace PID with the pid of the process)
Disclaimer: I'm working off my linux machine, so it is entirely possible that your file system layout is different
On most unix systems ps just shows the command name but
ps -ef
Will show the full path. Ps'es differ from unix to unix. If this doesn't work try
man ps
and look for "full" or "full format". Hope this helps.
ps often has a -f flag or something similar that will show you the full set of information. If that doesn't work, try using lsof for the process number you get from the ps command.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
We’re looking to run an application as a Service/Deamon on a Linux box without manually logging in and starting it. The application is a Java one that we start with a shell (.sh).
Do you know how to run a process on a Linux distribution as a service/deamon without logging in, manually start and stopping ?
Run a command on boot
You'd need to add the command that you would run, on /etc/rc.local.
Note: That path may be dependent on your distribution or init system, so check with the distributions documentation to make sure (ie it could be /etc/init.d/local or such).
One would typically
make that file executable -- chmod +x /etc/rc.local
and append/add in the contents the command that would run to start the application
$ echo "sh myscript.sh &" >> /etc/rc.local # or just edit with your prefered editor
Again, depending on your distribution and init system, you may need to add the file as a service on the default runlevel (or the appropriate runlevel)
sudo update-rc.d local defaults 80 # ie for ubuntu
Look at this howto for Ubuntu,
or look here for Archlinux,
or here for Gentoo
Remote part ?
The remote part has lots of trouble. What do you mean by remote ? Is the machine that runs the daemon in a Lan ? do you trust your lan ? does it communicate to the Internet ? etc
I would probably set up ssh on that machine, and whenever needed, I would log in and start/stop the daemon. You'd only need to set up sshd (typically /etc/ssh/sshd_config) and add ssh to run on boot.
If the machine is on a local Lan, and you believe that logging in and manually starting/stopping the daemon is too boring and want something more automated, I would probably write up a bot that would parse the mailbox for a specific user and upon receival of "special" mail, it would start or stop or toggle the status of the daemon (note it must have the appropriate permissions). That sounds easy, but you need to trust your lan or be careful on how you parse the mail (mail spoofing etc).
Assumption I assume you mean how you would get a Java service to start and stop at different run levels.
Take a look at the Java Service Wrapper it is an application which has evolved out of a desire to solve a number of problems common to many Java applications. The features of Wrapper are as follows:
Run a Java application as a Windows Service or UNIX Daemon
Java Application Reliability
Standard, Out of the Box Scripting
On Demand Restarts
Flexible Configuration
Ease Application Installations
Logging
The above spiel is from the website but I have used it extensively and its excellent. I can't recommend it enough.
In addition to other answers, you might use a #reboot crontab(5) entry
On Debian or Ubuntu, you could create your own service script by copying /etc/init.d/skeleton into your /etc/init.d/iccubedaemon (and edit that file appropriately) then symlinking it as /etc/rc2.d/S99iccubedaemon etc...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Without being the person logged in at the console, how do I run an X application and have it display on that X session? Assume I am either root, or I am the same user who logged in, so in principle I have persmission to do this. But how do I convince X of this?
Some examples of situations like this:
Log in with SSH and run a program that displays on the remote computer's screen (not tunneled through SSH—that is totally different)
A cron job to take a screenshot of the X session via ImageMagick's import command
Running a keystroke logger for audit purposes
This is a simpler version of Launch OpenGL app straight from a windowless Linux Terminal
The short answer is that you have to set the DISPLAY environment variable, and then the app will run.
The long answer is that we've got Xauth, and unless you're running as the same user on the same machine that's probably not going to work unless you export the Xauth credential from the account running the X server to the account running the X client. ssh -X handles this for you, which is why it's awesome, but the manual procedure involves running xauth extract - $DISPLAY on the X server account and feeding that data into xauth merge - on the client account. (Warning: the data is binary.)
On modern Linux systems, there is one X session at :0 and the X11 authority data file is always $HOME/.Xauthority so you can most often set two environment variables, for example, in Bash:
export XAUTHORITY=/home/$your_username/.Xauthority
export DISPLAY=':0'
The upshot is that you have to know the X display (placed in the DISPLAY environment variable) and the magic cookie (placed in a file, with the filename in the XAUTHORITY environment variable).
The quick-and-dirty way
On the system running X, if you are root or you are the same user who logged in to X, just assume the most common display and cookie files (works on almost any standard desktop install of any distro).
env DISPLAY=:0 XAUTHORITY=/home/whoever/.Xauthority /path/to/my/X/program
The more surefire way
Find them from the environment of an already-running X program. Again, if you are root or the same user who is logged in, this will tell you (if the user is using GNOME):
cat /proc/`pgrep -f ^x-session-manager`/environ \
| ruby -ne 'puts $_.split("\0").select { |e| e =~ /^(DISPLAY|XAUTHORITY)=/ }'