LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 04-18-2009, 09:33 AM   #1
lenny168
LQ Newbie
 
Registered: Apr 2009
Posts: 6

Rep: Reputation: 0
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?
 
Old 04-18-2009, 09:35 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
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
 
Old 04-18-2009, 09:50 AM   #3
lenny168
LQ Newbie
 
Registered: Apr 2009
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 04-18-2009, 11:05 AM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,817

Rep: Reputation: 609Reputation: 609Reputation: 609Reputation: 609Reputation: 609Reputation: 609
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'.
 
Old 04-18-2009, 11:50 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
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.
 
Old 04-18-2009, 12:37 PM   #6
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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.
 
Old 04-18-2009, 05:22 PM   #7
lenny168
LQ Newbie
 
Registered: Apr 2009
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 04-19-2009, 06:03 AM   #8
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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.
 
Old 04-19-2009, 09:39 AM   #9
lenny168
LQ Newbie
 
Registered: Apr 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rjlee View Post
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
 
Old 04-19-2009, 02:50 PM   #10
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem starting a program from a script via crontab Stefan J Linux - Newbie 4 04-14-2008 03:59 AM
Command for executing C program in crontab bhandu Linux - Newbie 1 07-14-2007 01:54 PM
SUSE 10.0 users not allowed to use crontab adamsml SUSE / openSUSE 2 02-01-2007 01:50 AM
Tracking user logins that was allowed and not allowed eswanepoel Linux - Security 3 08-02-2006 05:37 AM
want to run program every minute, crontab???? poj Linux - General 4 09-19-2005 05:29 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration