I have a configuration file that some of its lines is like below:

# Mandatory: no
# Range: 0-5
# Default:

I want to change the 3 at DebugLevel to 5 at 2 AM then after for example 2 hours at 4 AM it change back to 3 again. how can I do this? with crontab or script?


You can use sed to change the value at given time with cron:

To change DebugLevel=3 to DebugLevel=5 at 2am every day and then change back DebugLevel=5 to DebugLevel=3 at 4am every day, add following lines to your cron with crontab -e

0 2 * * * sed -i 's/DebugLevel=3/DebugLevel=5/g' file.conf
0 4 * * * sed -i 's/DebugLevel=5/DebugLevel=3/g' file.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.