Skip to content

Instantly share code, notes, and snippets.

@nancystodd
Forked from assertivist/snkeepalive.sh
Last active March 18, 2020 21:36
Show Gist options
  • Save nancystodd/a15520ea611d403ef2b12098a24723ea to your computer and use it in GitHub Desktop.
Save nancystodd/a15520ea611d403ef2b12098a24723ea to your computer and use it in GitHub Desktop.
keeps a ServiceNow developer instance awake, at least until the nightly snooze-all
#!/bin/bash
# put your instance id here
instance="dev######"
# make sure your password doesn't have shell operators in it
credentials="admin:password"
while true; do
entropy==$RANDOM
outdata="{\"short_description\":\"Automated incident $entropy\"}"
curl --user $credentials \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--request POST \
--data "$outdata" \
"https://$instance.service-now.com/api/now/table/incident"
echo "\n\n"
# Change the 1200 to the max number of time you need for the timer
# This is using seconds but if you need minutes, change the s to m
sleeptime=$(($RANDOM % 1200))s
echo "created incident, waiting $sleeptime"
sleep $sleeptime
done
@nancystodd
Copy link
Author

I was getting an error using rand so I changed it to use $RANDOM and now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment