LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 02-23-2010, 09:30 AM   #1
Rohaq
LQ Newbie
 
Registered: Nov 2005
Location: UK
Distribution: Kubuntu
Posts: 3

Rep: Reputation: 0
Editing other users' crontabs with STDIN


I want to edit another user's crontab with the output from STDIN. crotnab usage is apparently as follows:

Code:
crontab [file | -e | -l | -r ] [user]
But entering the following pops up with a 'proper usage' error:

Code:
cat test.cron | sudo crontab - username
Similarly, trying to take the input from a file has the same error:
Code:
sudo crontab /tmp/test.cron username
On the other hand, I can edit my own crontab with no problems:
Code:
cat test.cron | crontab
Error for all is as follows:
Code:
crontab: proper usage is: 
        crontab [file | -e | -l | -r ] [user]
I've trying to figure out the best way to do this - I want to do it from STDIN, rather than a file, since the command I'll be using outputs to STDOUT by default, however I don't even have the option to take input from a file, apparently!

If anyone could help with this, I would appreciate it.
 
Old 02-23-2010, 11:32 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
The usage message is misleading. The newer one is better:
Code:
crontab: usage:
	crontab [file]
	crontab -e [username]
	crontab -l [username]
	crontab -r [username]
 
Old 02-23-2010, 11:35 AM   #3
Rohaq
LQ Newbie
 
Registered: Nov 2005
Location: UK
Distribution: Kubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
Ah, so basically you can't feed STDIN into a specific user's crontab? That's rather annoying!
 
Old 02-23-2010, 12:24 PM   #4
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
Quote:
Originally Posted by Rohaq View Post
Ah, so basically you can't feed STDIN into a specific user's crontab? That's rather annoying!
It's probably not the proper way to do it but you could just edit the files directly in /var/spool/cron/crontabs/ and then restart cron...
 
Old 02-24-2010, 12:29 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by Rohaq View Post
Ah, so basically you can't feed STDIN into a specific user's crontab? That's rather annoying!
Crontab doesn't handle stdin when specified as "-" but there are other ways to do it. The simpler would be:
Code:
su username "crontab /dev/stdin"
 
  


Reply

Tags
crontab, crontabs, solaris, stdin



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
Is there a way to list all crontabs for all users? abefroman Linux - Server 6 09-29-2009 04:14 AM
editing users.bashrc to add a functions file dnoll17315 Linux - Newbie 1 03-27-2008 06:41 PM
How can I let non-root users build crontabs? dthacker SUSE / openSUSE 2 06-02-2006 03:22 PM
editing /etc/fstab--for rw permissions for all users koodoo Linux - Newbie 5 03-28-2005 12:37 AM
Whats the difference between all the crontabs (system, root, users) ? glenn69 Linux - Newbie 2 10-12-2004 07:41 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 06:19 AM.

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
Open Source Consulting | Domain Registration