M
M
Marat Taganov2020-12-14 23:27:42
ubuntu
Marat Taganov, 2020-12-14 23:27:42

Need help setting up crontab?

You need to set up a one-time deletion of a user after a certain amount of time, part of the code:

Del_port_user(){
  List_port_user
  while true
  do
    echo -e "Введите порт пользователя для удаления"
    read -e -p "(По умолчанию: отмена):" del_user_port
     && echo -e "Отмена..." && exit 1
    del_user=$(cat "${config_user_mudb_file}"|grep '"port": '"${del_user_port}"',')
    if ; then
      port=${del_user_port}
      match_del=$(python mujson_mgr.py -d -p "${del_user_port}"|grep -w "delete user ")
      if ; then
        echo -e "${Error} Удаление пользователя неуспешно ${Green_font_prefix}[Порт: ${del_user_port}]${Font_color_suffix} "
        break
      else
        Del_iptables
        Save_iptables
        echo -e "${Info} Удаление пользователя успешно ${Green_font_prefix}[Порт: ${del_user_port}]${Font_color_suffix} "
        echo
        read -e -p "Хотите продолжить удаление пользователей?[Y/n]:" delyn
         && delyn="y"
        if ; then
          break
        else
          echo -e "${Info} Продолжение удаления конфигурации пользователя..."
          Del_port_user
        fi
      fi
      break
    else
      echo -e "${Error} Введите корректный порт !"
    fi
  done
}

But I don't know how to make sure that the required user with a certain port can leave after 14 days. Never worked with cron.
If it's not hard to tell.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
planc, 2020-12-15
@planc

how to make sure that the desired user with a specific port can be deleted after 14 days.

https://man7.org/linux/man-pages/man8/usermod.8.html
-e, --expiredate EXPIRE_DATE
The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD.

Y
Yuriy Vorobyov, 2020-12-14
@YuriyVorobyov1333

Here you can play with crowns. The crown you need will most likely take this form 0 0 14 * *:. About launching the crown on ubunt here and here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question