0

My script.sh contains parameter expansion something like this

variable=${variable/PUT_CONTENT/$data}

This should replace the substring PUT_CONTENT with variable data. If I run the script manually in terminal like this: ./script.sh everything works (also the replacing). But the command with replacing doesn't work when I put the script.sh into the crontab file. I need run the script every 5 minutes. - None of variable expansion doesnt work in script which is started by cron.

*/5 * * * * sh -c "/root/script.sh"
Cyrus
  • 84,225
  • 14
  • 89
  • 153
S3jp4kCZE
  • 15
  • 6
  • have you verified the variables (`$variable` and `$date`) are being populated when the script is run via `cron`? how are these variables populated in the script? – markp-fuso Jan 01 '21 at 18:10
  • That should work but are you sure that the variables `variable` (not a good name) and `data` are defined in the context of the user owner of the cron job ? – davidxxx Jan 01 '21 at 18:11
  • 1
    I got it, the problem was that i didnt have the first line with `#!/bin/bash` – S3jp4kCZE Jan 01 '21 at 18:52

0 Answers0