View Single Post
grog's Avatar
Posts: 546 | Thanked: 85 times | Joined on Feb 2008 @ Winnipeg, Canada
#38
Originally Posted by allnameswereout View Post
I always use scripts because they're easier to modify.
I agree, except when the crontab line is so simple
To have crontab set up for user do crontab -u user. Also see the crontab man page, it would have easily explained this to you.
I have read the man page (lots of them over the years actually ), but since that option is only usable by root in the first place, I guess I didn't see the point in having to use root to set up a separate crontab for user when I could just use su in root's & keep everything together in the same one.
Code:
*/10 * * * * (DISPLAY=:0.0; rndback)
Edit: your 2nd command is incorrect because you don't use a ; after you set a environment. You put this before the environment, or you use export command (in Bash).
Except when surrounding the commands in braces as I did. This creates a separate sub-shell that will then encapsulate all of the included commands. You'd see the effect if you were to run each of the commands separately. The only difference between the 'var=val cmd' construct & 'var=val; cmd' is that the former sets the value of var only for the specified command. The latter sets it for the remainder of the session. The additional affect that an export would have is to make the variable available to sub-shells, which wasn't necessary here.
Code:
DISPLAY=:0.0
*/10 * * * * rndback
The 3rd won't work because you screwed the crontab file format. Probably, the issue is that the variable is not passed to the application, so you'd have to use export or a script.
There are several implementations of cron that accept this 'screwed' format to set variables globally for the entire crontab. As my tests indicated, this was not one of them, but it was worth a try because I have worked with implementations where it does work
But I recommend crontab for user in any case.
As I would on any 'normal' unix system. But then again, I'd never consider using 'user' as a userid, amongst other things.

Thanks for the help
__________________
GROG!
N900 | ZAGG Body Armour | 16Gb A-DATA micro-sd
N810 | 2 x Patriot 8gb mini-SD | Boxwave Crystal Clear SS | Black Aluminum case | OTG dongle
N800 | 2 x 8gb OCX SD | Boxwave Anti-glare SS | PDAir book-style case
Holux M-1200 bluetooth GPS | iGo 4-row bluetooth keyboard | Linksys USB 10/100 ethernet | Plantronics Voyager 855 BT Headset