Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
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
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)
Offline
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
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
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.
Offline
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