Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Trying to setup a Cron job on a remote server, when i try to run the command crontab -e. It says i am not allowed to use this program.
I login to the remote server by using ssh, e.g. ssh -l loginname remoteseverip. where i then enter a password. Basically i gain only access to my user area within the server. Do i need add something into the Cron job to tell it to run under my own user account?
Is having the root access to the server the only way around this issue? my plan was to setup a Cron job for a script that will ping and find ip addresses logged into the server and save it as a text file and have this done every hour.
You don't mention what distro you are running. As root, you probably have to add the user to a group that is allowed to use cron, which is probably 'cron'.
One possible option is that the administrator may have installed another task management program such as atd, which can be used to do regular jobs just like cron: http://linux.die.net/man/1/at
Or the system administrator may have simply locked down cron to stop you from using it. But you can still install cron separately onto your own user account. Warning: I've not tried this and it may not work. Basically, download the tarball, and install it using
Code:
./configure --prefix=/home/username/cron && make && make install
(where cron is a directory you have created). You should then be able to run
Code:
/home/username/cron/usr/sbin/crontab -e
(possibly usr/bin or just bin/ or sbin/). Don't forget to also run cron itself.
The simplest option, if you can't speak to whoever runs the server, is to write your own script to poll the time periodically and run your job whenever it needs to be run.
Thanks for the replies! Now am getting problems with my script! This is what i have so far:
#!/bin/bash
ip='ip addresses to ping'
for address in $ip;
do ping -c 1 -t 1 $host > /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
echo $address
fi
done > output.txt
for line in `cat output.txt`
do ssh $line | ps -ef
logout
done > test.txt
Basically the script should ping multiple ip addresses, store the results to a file. Then for each line in that file carry out a ps -ef command and then direct the results to another file.
I get the output.txt file and test.txt file when i run it, but for some reason it just hangs after that. I suspect its because the ssh hasn't stopped, but cannot seem to solve it.
I suspect your problem is the logout command, which is logging out of the current shell, since the ssh command will log out automatically when the ps command completes.
I suspect your problem is the logout command, which is logging out of the current shell, since the ssh command will log out automatically when the ps command completes.
Thanks for the reply rjlee, but upon removing the logout command and running the script again, it still hangs
lenny168, try putting echo lines into your script to find out where it is hanging.
You may want to redirect the output of echo to stderr so it doesn't get captured into files:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.