LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Crontab - Not allowed to use this program (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-not-allowed-to-use-this-program-720026/)

lenny168 04-18-2009 08:33 AM

Crontab - Not allowed to use this program
 
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?

Any ideas guru's?

repo 04-18-2009 08:35 AM

Quote:

It says i am not allowed to use this program
do you have root access to the server?
do you own the server?
if not, contact the administrator

lenny168 04-18-2009 08:50 AM

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.

AlucardZero 04-18-2009 10:05 AM

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'.

repo 04-18-2009 10:50 AM

Quote:

Is having the root access to the server the only way around this issue?
There is a reason why the user can not use cron.
So contact the administrator.

rjlee 04-18-2009 11:37 AM

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.

lenny168 04-18-2009 04:22 PM

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.

rjlee 04-19-2009 05:03 AM

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.

lenny168 04-19-2009 08:39 AM

Quote:

Originally Posted by rjlee (Post 3513915)
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

rjlee 04-19-2009 01:50 PM

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:

Code:

echo message 1>&2


All times are GMT -5. The time now is 12:38 PM.