Author Topic: Crontab as user  (Read 1960 times)

akhasis

  • Zen Apprentice
  • *
  • Posts: 39
  • Karma: +1/-0
    • View Profile
Crontab as user
« on: June 27, 2013, 03:01:08 pm »
Hello,

I'm trying to backup some files periodically from my zentyal server to another computer (Win2003 server), but I wouldn't like to use the admin user, so I created a user ("backup_user") specifically in that Win2003 server for that task.That user is also exists in my zentyal server.

that user already mounted a directory shared from the w2003s. I'd like to create a cron job for that user that executes every day. How can I run that cron job as the user "backup_user"?

Thank you!

christian

  • Guest
Re: Crontab as user
« Reply #1 on: June 27, 2013, 03:16:34 pm »
what's your question exactly ?
use of
Code: [Select]
crontab -e ?
command to be used in crontab ?
doing it using Zentyal GUI ?

When logged as backup_user, can easily edit crontab (for this user) and run your copy from source to destination assuming both are mounted.

jbahillo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1444
  • Karma: +77/-2
    • View Profile
Re: Crontab as user
« Reply #2 on: June 27, 2013, 06:46:50 pm »
Just adding one more possibility to christian words, if for chance it fit to this scenario

Code: [Select]
sudo crontab -u backup_user -e

allows you to edit the crontab for a user you have not logged into

akhasis

  • Zen Apprentice
  • *
  • Posts: 39
  • Karma: +1/-0
    • View Profile
Re: Crontab as user
« Reply #3 on: June 28, 2013, 09:05:05 am »
Sorry i wasn't able to make myself clear. My question was, since I can't log in to zentyal as any other user than admin, how to edit backup_user's crontab.

Thank you both for your answers, they were very useful.

half_life

  • Bug Hunter
  • Zen Hero
  • *****
  • Posts: 867
  • Karma: +59/-0
    • View Profile
Re: Crontab as user
« Reply #4 on: June 30, 2013, 03:26:48 am »
The other useful trick is knowing how to sudo up to the root account and have a prompt to work from.

sudo su allows you to switch to the root user.
Once you are root, you can simply su <my_other_user>  to work as them for awhile.  Exit backs you out one layer at a time.

akhasis

  • Zen Apprentice
  • *
  • Posts: 39
  • Karma: +1/-0
    • View Profile
Re: Crontab as user
« Reply #5 on: July 01, 2013, 08:33:39 pm »
That is very interesting, I had no idea I could connect as another user apart from root. Thank you!