Home > Net >  Cron in bash (linux)
Cron in bash (linux)

Time:01-08

I need to add this script to cron. For example, make a backup every week. But I don't know how to pass values. The script doesn`t have any arguments, bat values read from the console. Can you help me, please?

#!/bin/bash
read -p "Write what you want or -h to know how script works:  " command
if [ $command = "backup" ]
then
    IFS="~"
    read -p "Write  extensions of file to backup:   " exts
...
    ```

CodePudding user response:

Write a driver script that provides input to the script via a here-document.

#!/bin/bash

/path/to/backup_script <<EOF
backup
ext1~ext2~ext3
EOF

Then put this driver script in crontab.

  •  Tags:  
  • Related