Context
Suppose one would like a single Bash installation script named install.sh
to ensure Ubuntu 22.04 runs the command: picard
(which launches a GUI), at boot (in the background, without showing the GUI).
Approach
I looked at: https://askubuntu.com/a/816/846880 which allows one to do this manually by typing:
crontab -e
[1] (to select the favourite editor)
@reboot /path/to/script
However, I would like the cronjob to be set up automatically instead of manually. So I looked in GitHub: and found this install script which contains:
#para crontab -e
#echo "@reboot sudo /home/pi/ili9342-driver/fbcp-ili9342" >> mycron; crontab mycron;rm mycron
Issue
However, that does not take into account whether the desired line already is in the crontab.
Question
Hence, I was wondering to know how to make a single Bash script automatically run the command picard
at boot? (Ideally in the background without showing the GUI)
crontab -l | grep "some string in the desired line"
. Then use conditional logic to do the next step. – user68186 Jun 13 '22 at 22:08