Red Hat Certified System Administrator RHCSA · Free Practice Question Medium
Question 31
As the root user on a Red Hat Enterprise Linux 9 system, schedule a cron job to execute the disk command 'df -h'. This job should run daily at 4:15 pm and the output needs to be appended to the file located at /tmp/diskstatus.
Show model answer
To create this cron job in RHEL 9, first open the crontab for editing with crontab -e as root. Then add the following line:
15 16 * * * /bin/df -h >> /tmp/diskstatus
This line schedules the df -h command to run every day at 4:15 pm. The >> operator is used to append the output to /tmp/diskstatus. If this file doesn't exist, it will be created. Remember to ensure the file's permissions are set appropriately for your requirements.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
