Score:0

GAWK not running in crontab

cn flag

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
Arnaud Valmary avatar
in flag
What is the error ? (put a redirection to a file (i.e. ` 2>/tmp/cron_autoscript.err`) in your crontab to observe it)
user9517 avatar
cn flag
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 avatar
cn flag
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.
serverstackqns avatar
cn flag
@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.
Zareh Kasparian avatar
us flag
which user this script should run with? if root, then you missed the use in your crontab
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.