Advertisement
sergio_educacionit

cron_abm-v4.sh

Oct 5th, 2022 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # traemos el fichero de funciones
  4.  
  5. source funciones
  6.  
  7.  
  8. # Parametros
  9.  
  10. arr_params=( $1 $2 )
  11.  
  12.  
  13. cron_dir="/var/spool/cron/crontabs"
  14.  
  15. cron_tab="0 1 * * * /bin/false"
  16.  
  17. user="${arr_params[1]}"
  18.  
  19.  
  20. case ${arr_params[0]} in
  21.  
  22.     -h|--h)
  23.         func_help
  24.         exit   
  25.         ;;
  26.     -c)
  27.         if ! func_root ;then
  28.             func_help
  29.             exit 1
  30.         elif ! func_user $user; then
  31.                 exit 1
  32.         else
  33.             echo "$cron_tab" >> $cron_dir/${arr_params[1]}
  34.         fi
  35.     ;;
  36.     -d)
  37.         if func_root ;then
  38.            
  39.             rm $cron_dir/${arr_params[1]}
  40.         else
  41.             func_help
  42.             exit 1
  43.         fi
  44.  
  45.     ;;
  46.     -i)
  47.     cat $cron_dir/${arr_params[1]}
  48.     ;;
  49.     *)
  50.     echo "No se paso niguna opcion válida o el usuario no existe"
  51.     exit 1
  52.  
  53. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement