Search code examples
linuxcron

CRON Job that changes a txt file


My name is Colin.

I want my Linux server to edit a file at 0am. It should change some values in a txt file (Randomized). I heard about CRON Jobs but I don't know how to use them. I hope somone can help me with my problem :)

Thank you for your answers.

Regards, Colin


Solution

  • You can add a new crontab with: crontab -e. Please notice that this crontab runs with the privileges of the user that inserted it.

    If you want to run a program always at midnight you can use this line:

    0 0 * * * <COMMAND TO EXECUTE> > <PATH TO FILE TO WRITE OUTPUT AND ERRORS> 2>&1
    

    A short introduction how to configure the time when a cronjob is running:

    Source: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/

    For more informations you can visit this page: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/