Skip to content

Instantly share code, notes, and snippets.

@EmilVarona
Created August 27, 2016 07:34
Show Gist options
  • Save EmilVarona/47ae4cf5d638cfeba70408c0d8d556f3 to your computer and use it in GitHub Desktop.
Save EmilVarona/47ae4cf5d638cfeba70408c0d8d556f3 to your computer and use it in GitHub Desktop.
add line to user crontab by script
#!/bin/bash
if [[ -z $1 ]]; then
echo ERROR: no target user ID given'
exit 1
else
someUser=$1
fi
sudo /bin/bash -c "echo \*/2 \* \* \* \* /my/command >> /var/spool/cron/${someUser}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment