Basically I want to create a directory at some fixed time and after exactly five minutes, I want to create a text file in that directory.
I tried this code but it didn't work
6 13 * * * /usr/bin/mkdir /qwerty /usr/bin/touch file1
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Here is the command you asked cron to run:
/usr/bin/mkdir /qwerty /usr/bin/touch file1
mkdir with tree parameters:
mkdir will attempt to create those as directories.
You probably meant to run those as two separate commands:
6 13 * * * /usr/bin/mkdir /qwerty 11 13 * * * /usr/bin/touch /qwerty/file1
Another style would do this as a one-liner:
6 13 * * * /usr/bin/mkdir /qwerty && sleep 5m && /usr/bin/touch /qwerty/file1
Note that using cron for one-off jobs is strange; as mentioned in a comment to your question, an at job would make more sense.
Also, this will still fail unless the user is allowed to create
$ echo "mkdir test && sleep 300 && touch test/file" | at 06:13
This will schedule the echoed command to run at 06:13. If 06:13 has already passed, it will be run at that time tomorrow.
Any output from the job will bu mailed to you.
at manual for the different ways you may specify the time.