Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Screen inside Jails + su

51 views
Skip to first unread message

Wael Nasreddine

unread,
Apr 8, 2008, 6:00:05 PM4/8/08
to FreeBSD Mailing Lists
Hello,

I have a FreeBSD server which is Jails based, I have created a special
jail to run 3 rTorrent process for 3 users, I made all the permissions
and added the users, then I launched manually (for testing purpose)
these screen sessions for the 3 users using the below method:
- jexec onto the jail.
- su to the user: su -l wael
- run a detached screen: screen -dmS Rtorrent
I have a .screenrc for each user in place to run one command,
rtorrent

Now I have 2 questions:
1) How can I add this procedure to the jail startup??
2) I can't attach the screen, everytime I try to I get an error:
# su -l wael
% screen -Dr Rtorrent
Cannot open your terminal '/dev/ttyp6' - please check.
What's going on? why can't I attach the screen session ??

Thanks :)

--
Wael Nasreddine
http://wael.nasreddine.com
PGP: 1024D/C8DD18A2 06F6 1622 4BC8 4CEB D724 DE12 5565 3945 C8DD 18A2

/<o>\ I had a friend who was ready for a memory upgrade on his Mac notebook, and he
/<o>\ wanted to know how much "megaram" he needed.

Wael Nasreddine

unread,
Apr 8, 2008, 9:05:03 PM4/8/08
to FreeBSD Mailing Lists, Erik Osterholm
This One Time, at Band Camp, Erik Osterholm <freebsd-l...@erikosterholm.org> said, On Tue, Apr 08, 2008 at 07:52:17PM -0500:
> On Wed, Apr 09, 2008 at 12:00:05AM +0200, Wael Nasreddine wrote:

> The common way for a user to run a program at startup is to use cron
> with the special @reboot directive instead of giving it a time to run
> a job.
> http://www.freebsd.org/doc/en/books/handbook/configtuning-starting-services.html

Thank you for pointing that out, could you please give me an example I
haven't found on that page...

> If you have used jexec to get into the jail, then you won't have a pty
> within the jail, and anything which relies on one will fail to
> execute. Start up sshd in the jail, then ssh to it and see if you can
> attach the screen.
Thanks that worked fine...

> Erik


--
Wael Nasreddine
http://wael.nasreddine.com
PGP: 1024D/C8DD18A2 06F6 1622 4BC8 4CEB D724 DE12 5565 3945 C8DD 18A2

/<o>\ Man has never reconciled himself to the ten commandments.

Erik Osterholm

unread,
Apr 8, 2008, 8:52:17 PM4/8/08
to FreeBSD Mailing Lists
On Wed, Apr 09, 2008 at 12:00:05AM +0200, Wael Nasreddine wrote:
> Hello,
>
> I have a FreeBSD server which is Jails based, I have created a special
> jail to run 3 rTorrent process for 3 users, I made all the permissions
> and added the users, then I launched manually (for testing purpose)
> these screen sessions for the 3 users using the below method:
> - jexec onto the jail.
> - su to the user: su -l wael
> - run a detached screen: screen -dmS Rtorrent
> I have a .screenrc for each user in place to run one command,
> rtorrent
>
> Now I have 2 questions:
> 1) How can I add this procedure to the jail startup??

The common way for a user to run a program at startup is to use cron


with the special @reboot directive instead of giving it a time to run
a job.
http://www.freebsd.org/doc/en/books/handbook/configtuning-starting-services.html

> 2) I can't attach the screen, everytime I try to I get an error:
> # su -l wael
> % screen -Dr Rtorrent
> Cannot open your terminal '/dev/ttyp6' - please check.
> What's going on? why can't I attach the screen session ??

If you have used jexec to get into the jail, then you won't have a pty


within the jail, and anything which relies on one will fail to
execute. Start up sshd in the jail, then ssh to it and see if you can
attach the screen.

Erik

Erik Osterholm

unread,
Apr 9, 2008, 2:42:16 PM4/9/08
to FreeBSD Mailing Lists
On Wed, Apr 09, 2008 at 03:05:03AM +0200, Wael Nasreddine wrote:
> This One Time, at Band Camp, Erik Osterholm <freebsd-l...@erikosterholm.org> said, On Tue, Apr 08, 2008 at 07:52:17PM -0500:
> > On Wed, Apr 09, 2008 at 12:00:05AM +0200, Wael Nasreddine wrote:
>
> > The common way for a user to run a program at startup is to use
> > cron with the special @reboot directive instead of giving it a
> > time to run a job.
> > http://www.freebsd.org/doc/en/books/handbook/configtuning-starting-services.html
>
> Thank you for pointing that out, could you please give me an example
> I haven't found on that page...

Sure.

At your shell prompt, type:
man 5 crontab

You'll find the man page for the crontab file, which includes multiple
examples of cron entries. All of those use the time specification,
though, rather than the @reboot keyword.

An example using @reboot:
@reboot /usr/local/bin/screen -d -m Rtorrent

You can edit the crontab for the user with this command at your shell
prompt:
crontab -u username -e

This will dump you into your editor, editing the crontab file for the
user "username". Type in the crontab entry (for example, the one I
used as an example above), save, and try restarting the jail.

Erik

Wael Nasreddine

unread,
Apr 9, 2008, 3:05:44 PM4/9/08
to FreeBSD Mailing Lists
This One Time, at Band Camp, Erik Osterholm <freebsd-l...@erikosterholm.org> said, On Wed, Apr 09, 2008 at 01:42:16PM -0500:
> Sure.

> At your shell prompt, type:
> man 5 crontab

> You'll find the man page for the crontab file, which includes multiple
> examples of cron entries. All of those use the time specification,
> though, rather than the @reboot keyword.

> An example using @reboot:
> @reboot /usr/local/bin/screen -d -m Rtorrent

> You can edit the crontab for the user with this command at your shell
> prompt:
> crontab -u username -e

> This will dump you into your editor, editing the crontab file for the
> user "username". Type in the crontab entry (for example, the one I
> used as an example above), save, and try restarting the jail.

Thank you, I googled a bit yesterday actually and now it's working
perfectly :)

I use linux since 6 years and I've never seen this reboot command
actually, but I'm used to cron, but thanks a lot for pointing this out,
it's very useful :)

> Erik

--
Wael Nasreddine
http://wael.nasreddine.com
PGP: 1024D/C8DD18A2 06F6 1622 4BC8 4CEB D724 DE12 5565 3945 C8DD 18A2

/<o>\ The mark of a good party is that you wake up the next morning wanting to
/<o>\ change your name and start a new life in different city.
/<o>\ -- Vance Bourjaily, "Esquire"

0 new messages