1. Create a. sh file (such as timetask.sh) to define the commands that need to be executed on a timed basis
e.g
#!/bin/sh
Cd/usr/local/drivebehavior/aliyunserver
Nohup/usr/local/matlab/r2013b/bin/matlab <main.m 1>running.log 2>running.err &
Where the first line of #!/bin/sh is the required execution command for the script, the second behavior requires the specified run directory, and the third behavior Target command, which is the task that needs to be performed.
2. Type crontab-e edit crontab service file
e.g
XX 3 * * */bin/sh/usr/local/drivebehavior/aliyunserver/timetask.sh
Where,/bin/sh is the execution of the command, the time is 3 o'clock in the morning per day
Save the file and exit
3. To see if the Crontab service under this user is created successfully, use the CRONTAB-L command
4, use the command sudo service cron Restart restart the scheduled task!
So, the whole process is done.
Reference Links: http://www.blogjava.net/freeman1984/archive/2010/09/23/332715.html
Linux Timing Task Detailed---matlab background run