活到老学到老  

记录遇到问题的点点滴滴。

linux指定nologin用户执行命令

6年前发布  · 1527 次阅读
  nologin 

为了安全,使用nologin账号来运行程序,

su -s /bin/bash -c "ls" www

这条命令到底做了什么呢?su -s 是指定shell,这里www用户是nologin用户,是没有默认的shell的,这里指定使用/bin/bash, -c 后面接需要运行的命令, 后面www是用www用户来运行

 

crontab 使用其他用户做计划任务

如果是crontab -u -e 

sudo su - www crontab -e

或者直接编辑/etc/crontab文件

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed