Hello everyone! I’m looking for some guidance on creating a script that automates the periodic update of all programs, including those from the AUR, every 3 hours. I’m thinking of setting up a crontab or something similar to ensure that the updates are performed automatically and regularly. Additionally, I’d like the script to be idempotent, meaning that running it multiple times won’t change the result.
Furthermore, if possible, I’d also like to extend this script to automatically install the latest kernels when they become available.
I would like to have this functionality in a function so that I can add it to my post-install script. Any guidance or suggestions on how to achieve this would be greatly appreciated.
sudo timeshift --create --comments "Before system update"
pamac update --aur --no-confirm
current_kernel=$(pacman -Qqs linux[0-9] | grep -Po 'linux\d+$' | tail -1)
latest_kernel=$(mhwd-kernel -l | grep -Po 'linux\d+$' | tail -1)
if [[ $latest_kernel > $current_kernel ]]; then
if ! sudo mhwd-kernel -i $latest_kernel; then
echo "Error installing $latest_kernel"
CRON_JOB="0 */3 * * * /usr/bin/sudo $CRON_FILE"
# Create a new crontab file for root if it doesn't exist
if ! sudo crontab -l -u root >/dev/null 2>&1; then
echo "# Automatically generated by setup_auto_update()" | sudo tee /var/spool/cron/crontabs/root >/dev/null
sudo chown root:crontab /var/spool/cron/crontabs/root
sudo chmod 600 /var/spool/cron/crontabs/root
# Add the cron job if it doesn't exist
if ! sudo crontab -l -u root | grep -q "$CRON_FILE"; then
(sudo crontab -u root -l; echo "$CRON_JOB") | sudo crontab -u root -
To check if a cron job is running as expected, you can check the system logs to see if the job has been executed at the expected time. The system logs can be found in /var/log/syslog or /var/log/cron.
To check if the cron job defined in the setup_auto_update() function is running as expected, you can wait for the next scheduled run time (in this case, every 3 hours) and then check the system logs for any messages related to the cron job.
For example, if the cron job is scheduled to run at 12:00 PM, you can wait until 3:00 PM and then check the system logs for any messages related to the cron job by running the following command:
This command searches the system logs for any messages containing “CRON” (which indicates that a cron job has been executed) and “update_system_and_kernel.sh” (which is the name of the script that the cron job executes). If the cron job has been executed successfully, you should see a message similar to the following:
This message indicates that the cron job was executed by the root user at 3:00 PM. If you don’t see any messages related to the cron job, it may indicate that the cron job is not running as expected and you should investigate further.
Please note that Manjaro is an OS, geared towards consumer/advanced home user.
What you are going to do (updating and automatically answering on every question with yes without thinking) will eventually break the system. Please do not shoot youself in the leg although we gave you a gun.
There are more suitable setups that are / can be completely unattended. Like a cloud provider that offers containerized os-es and updates the containers automatically.
And the from those over 100 links about 90 are irrelevant. As everybody that has worked with chatgpt should know by now, the bot is really good in making up fake/irrelevant bibliography, just to look like backing up a thesis…that it just made up
P.s. i bet Individual-heart718 is working in an it department somewhere in India. He gets a task from his boss, feeds the question through the bot, and posts here so that we correct the errors that the stupid bot made…and voila, did his job and receives his salary.
Why don’t you go talk about it somewhere else? You are being more useless than the AI, at least it understands the question and gives relevant information, it doesn’t ramble about bots. Do you think people who browse online and find this question want to hear you complaining about the bots writing fake links?
And do you truly believe this is the appropriate place to say that when there are private messages available? After I corrected the post, your mention of AI links is unrelated to the discussion, and despite my request for you to refrain from doing so, you continue to bring it up.