DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-08-27 21:03:14

boupartac
Member
From: Montréal, Québec, Canada
Registered: 2008-07-29
Posts: 38

Crontab as nobody

Hi all,

I just created a bash script and I would like it to run every 5 minutes on my DNS-323, as user nobody. What are the steps to do so?

Thanks,

boupartac

Last edited by boupartac (2008-08-27 21:23:50)

Offline

 

#2 2008-08-28 01:11:06

ismora
Member
From: Paris, France
Registered: 2008-07-30
Posts: 30

Re: Crontab as nobody

Maybe you can try to add in /var/spool/cron/crontabs/root :
*/5 * * * *       su - -c "/path/to/the/command"

Last edited by ismora (2008-08-28 01:12:07)


DNS-323 • 2x Hitachi 500MB • RAID1 • FW1.04 • ext3 • Fonz's v0.5 fun_plug
DNS-325 • 2x WD Green 2TB • RAID1 • FW?.?? • ext3 • Fonz's v0.7 fun_plug

Offline

 

#3 2008-08-29 22:47:10

SweMart
Member
From: Stockholm, Sweden
Registered: 2008-03-18
Posts: 14

Re: Crontab as nobody

ismora wrote:

Maybe you can try to add in /var/spool/cron/crontabs/root :
*/5 * * * *       su - -c "/path/to/the/command"

That would run the command as root.

An alternative would be:
*/5 * * * *       su - nobody -c "/path/to/the/command"

Or even better:
1. su to root
2. crontab -u nobody
3. Add the following line
*/5 * * * *       /path/to/the/command 2>&1 > /dev/null

Offline

 

#4 2008-09-02 18:19:51

boupartac
Member
From: Montréal, Québec, Canada
Registered: 2008-07-29
Posts: 38

Re: Crontab as nobody

Thanks everyone. Do I have to include anything concerning the path? Resourcing /etc/profile or whatever? I am wondering, because my script runs when I execute it, but in crontab, it doesn't work (I have included full path for commands).

Last edited by boupartac (2008-09-02 18:21:12)

Offline

 

#5 2008-09-03 10:20:01

ismora
Member
From: Paris, France
Registered: 2008-07-30
Posts: 30

Re: Crontab as nobody

because my script runs when I execute it, but in crontab, it doesn't work

Are you sure that it is executed?
Maybe try to put something simple in the same crontab, typically
  /bin/echo "hello" > /tmp/hello
to be sure that cron actually treats your command.

An alternative would be:
*/5 * * * *       su - nobody -c "/path/to/the/command"

This is what I intended to write indeed, but the "nobody" got out of the way.

I am also aware that /var/spool/cron/crontabs/nobody is a cleaner solution, but in fact I have some strange behaviors with cron on my DNS:
- no crontab other than /var/spool/cron/crontabs/root is taken in account (no way with /etc/crontab, /var/spool/cron/crontabs/ismora, ...), which led me to the "su -c" trick
- whether I directly edit /var/spool/cron/crontabs/root, or I use "crontab -e" as root, any new line that I add is not executed; I have to kill the crond process then launch another one to have the updates taken in account.
This is different from the cron program behavior I am used to (checking /var/spool/cron/crontabs/ every minute and automatically taking care of new lines or files).
But maybe this is me, maybe I missed something obvious, I realize now that maybe there is some /etc/cron.deny file, and I don't have access to my DNS right now to check.


DNS-323 • 2x Hitachi 500MB • RAID1 • FW1.04 • ext3 • Fonz's v0.5 fun_plug
DNS-325 • 2x WD Green 2TB • RAID1 • FW?.?? • ext3 • Fonz's v0.7 fun_plug

Offline

 

#6 2009-05-17 23:18:38

cybernauta
New member
Registered: 2009-04-24
Posts: 4

Re: Crontab as nobody

I have an issue with crontab with my dns-323 and i would like your help.

I installed transmission. After around 3/4 hours the program stops seeding (don't know why). The solution for this is to restart the program. For this i'm trying to use crontab.

1º attempt
- edited the normal crontab and added some lines.
- problem - when I restart the NAS the lines that I added disappear.

2º attempt
- created a script as mentioned here already that replaces cron and restarts it:
----------------------
# if crontab file exists on disk
if [ -e /mnt/HD_a2/ffp/start/etc/crontab.txt ]; then
        # install the new crontab
        /bin/crontab $CRONTXT
else
        # else dump existing cron to disk
        /bin/crontab -l > $CRONTXT
fi

# Restart crontab
/sbin/crond restart
----------------------
- PROBLEM - the crontab doenst restart. I can see the old crond running and the restart command still in progress:
1377 root     crond (old cron)
1561 root     /sbin/crond restart (the command still in progress


Can someone help me with this ? Tks.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB