How to set cronjob with non-root user?

前端 未结 3 2034
情深已故
情深已故 2021-01-05 06:24

Error : crontab: must be suid to work properly

I want to set cronjob in docker container with non-root user. Is it possible to set a cron without using sudo and wi

3条回答
  •  旧时难觅i
    2021-01-05 06:56

    /etc/crontab is the system wide crontab.

    The format of /etc/crontab is like this:

    # m h dom mon dow user      command
    *   *  *   *   *  someuser  echo 'foo'
    

    while crontab -e is per user, it's worth mentioning with no -u argument the crontab command goes to the current users crontab. You can do crontab -e -u to edit a specific users crontab.

    Notice in a per user crontab there is no 'user' field.

    # m h  dom mon dow  command
    *   *   *   *   *   echo 'foo'
    

    An aspect of crontabs that may be confusing is that root also has its own crontab. e.g. crontab -e -u root will not edit /etc/crontab

    See Configuring cron for more information: https://www.freebsd.org/doc/handbook/configtuning-cron.html

    In most Linux distros, per user crontabs are typically stored in: /var/spool/cron/crontabs/

提交回复
热议问题