0

I have the below script running successfully manually. But when it is executed in crontab (below), I dont see anything happening.

Script

#!/usr/bin/gawk -f
#!/bin/bash

PATH=/usr/local/bin:/usr/bin

#Reading from the file & storing in array
array=()
while read -r line; do
array+=($line)
done < /etc/folder/automation-script/ip.txt

#Removing the lines based on line number of file

gawk -i inplace 'NR==30 {next} {print}' /etc/folder/default.vcl
gawk -i inplace 'NR==38 {next} {print}' /etc/folder/default.vcl

#Adding lines based on line number of VCL file

gawk  -i inplace -v line1=${array[0]} 'NR==30{print ".host = ""\042"line1"\042"";"}1' /etc/folder/default.vcl
gawk -i inplace -v line2=${array[1]} 'NR==39{print ".host = ""\042"line2"\042"";"}1' /etc/folder/default.vcl

Crontab

35 04 16 11 * /etc/folder/automation-script/autoscript.sh
serverstackqns
  • 764
  • 3
  • 16
  • 42
  • What is the error ? (put a redirection to a file (i.e. ` 2>/tmp/cron_autoscript.err`) in your crontab to observe it) – Arnaud Valmary Nov 16 '22 at 07:19
  • Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it) – user9517 Nov 16 '22 at 08:39
  • The close duplicate will almost certainly help to solve your issue. If it does not it will help you gather information to edit into your question that will help people help you. – user9517 Nov 16 '22 at 08:40
  • @user9517, Using "Capture the output yourself" in the above link, there's no log file created to check for error. there are some other commands which are executing successfully, but not gawk. – serverstackqns Nov 16 '22 at 11:09
  • which user this script should run with? if root, then you missed the use in your crontab – Zareh Kasparian Jan 19 '23 at 14:11

0 Answers0