diff --git a/Scheduling-exports-with-Mono-&-Crontab.md b/Scheduling-exports-with-Mono-&-Crontab.md index 179f951..f0619f9 100644 --- a/Scheduling-exports-with-Mono-&-Crontab.md +++ b/Scheduling-exports-with-Mono-&-Crontab.md @@ -1,4 +1,8 @@ -Make sure you already have DiscordChatExporter and Mono properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Linux-usage-instructions)): +Make sure you have DiscordChatExporter and Mono properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Linux-usage-instructions)). + +You can use Crontab on macOS, but [this method](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Scheduling-exports-on-macOS) is preferred. + +# **1.** Open Terminal, create a new script with `sudo nano /path/to/DiscordChatExporter/cron.sh` @@ -6,7 +10,8 @@ Make sure you already have DiscordChatExporter and Mono properly installed ([ins ``` #!/bin/bash -# Info: https://github.com/Tyrrrz/DiscordChatExporter +# Info: https://github.com/Tyrrrz/DiscordChatExporter/wiki + TOKEN= TOKENTYPE= CHANNEL= @@ -22,8 +27,11 @@ if [[ "$TOKENTYPE" == "BOT" ]]; then ISBOTYES=-b fi +PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin + mono DiscordChatExporter.Cli.exe -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o exporttmp CURRENTTIME=`date +"%Y-%m-%d-%H-%M-%S"` + if [[ "$EXPORTFORMAT" == "PlainText" ]]; then mv "exporttmp" $EXPORTDIRECTORY/$FILENAME-$CURRENTTIME.txt @@ -42,7 +50,7 @@ exit `` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) - `` If the Token is from a bot replace it with `BOT`, if it's from a user, `USER`. + `` If the Token is from a bot replace it with `BOT`, if it's from a user, `USER` `` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) @@ -52,13 +60,13 @@ exit `` with the export directory without quotes (e.g. /home/user/Documents/CronExport) - `` with one of the available export formats. + `` with one of the available export formats **4.** Give the shell script permissions with `sudo chmod 755 /path/to/DiscordChatExporter/cron.sh` **5.** Add a new job to crontab using `sudo crontab –e` -**6.** Add `* * * * * /path/to/DiscordChatExporter/cron.sh` to the end of the file. +**6.** Add `* * * * * /path/to/DiscordChatExporter/cron.sh >/tmp/discordexporter.log 2>/tmp/discordexportererror.log` to the end of the file Replace the *s according to: @@ -71,6 +79,8 @@ Week starts on Sunday. 0 = SUN, 1 = MON... Filename date format is YYYY-MM-DD-hh-mm-ss. +The cron file is located at `/usr/lib/cron/tabs` on macOS, and at `/var/spool/cron/crontabs` on Linux, but should always be edited with `crontab -e`. + # **Examples**