You can't mix a schedule with
cron doesn't support that.
If you want to open a file at Linux startup on a specific date, do this:
Write a script (chkdate.sh) that checks the date for a match to (for example) May 2
@reboot spec in
cron to run
chkdate.sh, a script to check today's date against a specific date]:
You could write a
bash script to accomplish this. The
date function in
bash will return today's date. Having that, you only need then to test today's date against the specific date, and take the desired action. Here's one way to approach this:
NOTE: I use a Debian-based Linux distribution, so what follows reflects that. Your system may vary somewhat.
- Use the
date function: Open a "terminal window", or simply get the command prompt on your system. At the command prompt (
$ in my case), type
$ date +%Y-%m-%d
- Specify the
date format needed:
date can provide its output in a variety of different formats. In the example above, the format is "Year-month-day". If you are interested only in the month and day, then the command would be:
$ date +%m-%d
- Regardless of the format you need, you must learn to use the system documentation. To learn how to instruct
date to provide its output in the format you need, you will need to read its documentation:
$ man date
Note that the single character
q will close the
- Once you've decided on the format of the
date output, you can begin to write the script
chkdate.sh. Let's create the file, and open it in an easy-to-use text editor:
$ nano ~/chkdate.sh
You may begin entering your script; for example:
if [ $TODAY == $SOMEDAY ]
echo "Today is the day!"
echo "Today is NOT the day."
Now, save the file
^o, and exit the
- You will need to set the file permissions to make the script executable, and you may then run it:
$ chmod 755 ~/chkdate.sh
Today is the day!
Because today is May 2nd, the
then condition of the
if statement is executed (
echo "Today is the day!"). On any other day of the year, the
else statement would be executed. Also note that it is not necessary to have an
else condition - you may simply omit it if you don't need it.
- Assuming this executes, you can modify the script to replace the
echo ... command(s) with the command(s) you want to use.