editing crontable help!
everyone (who knows Linux/unix) can edit the crontable (of the current user) via the command
$ crontab -e
and a little VI type application runs where you can edit your scheduled applications. in reality, these are all stored in files /var/spool/cron/username (for red hat-like systems). issuinig the command
# cat /var/spool/cron/root
will reveal the cron table for root. You can also view other users' cron tables. The only problem is, all these files are owned by root. Each user file belongs to the group of the user. It looks like something like this
# ls-l /var/spool/cron/
total 8
-rw------- 1 root user1 195 Sep 7 02:58 user1
-rw------- 1 root root 151 Sep 4 06:05 root
My simple task was to edit the cron table of the user and insert the cron job using one command, like this
echo '* * * * * blah blah' >> /var/spool/cron/user1
but you can only do that if you are root. changing the permissions of the cron table file will cause the crontable to be invalid. I only found that out when i digged out the cron logs and saw this line:
Sep 7 02:29:01 hostname crond[1923]: (user1) BAD FILE MODE (cron/user1)
Sep 7 02:30:01 hostname crond[1923]: (user1) BAD FILE MODE (cron/user1)
after a little googling, I found that other people had similar problems. The guy said something about NOT changing the permissions. (
link here )
I you guys read my earlier entries, you would notice a 'pattern' in my posts. I want to run these scripts from another server and automating them in one-line commands. As much as possible I don't want to use root to do the dirty work, nor would i want to give my user root permissions. hmmmm
think think think....